@@ -120,11 +120,33 @@ type CreateClientActionArgs<T extends RouteInfo> = ClientDataFunctionArgs<
120120 serverAction : ( ) => Promise < ServerDataFrom < T [ "module" ] [ "action" ] > > ;
121121} ;
122122
123- type CreateHydrateFallbackProps < T extends RouteInfo > = {
123+ type IsServerFirstRoute <
124+ T extends RouteInfo ,
125+ RSCEnabled extends boolean ,
126+ > = RSCEnabled extends true
127+ ? T [ "module" ] extends { ServerComponent : Func }
128+ ? true
129+ : false
130+ : false ;
131+
132+ type CreateHydrateFallbackProps <
133+ T extends RouteInfo ,
134+ RSCEnabled extends boolean ,
135+ > = {
124136 params : T [ "params" ] ;
125- loaderData ?: T [ "loaderData" ] ;
126- actionData ?: T [ "actionData" ] ;
127- } ;
137+ } & ( IsServerFirstRoute < T , RSCEnabled > extends true
138+ ? {
139+ /** The data returned from the `loader` */
140+ loaderData ?: ServerDataFrom < T [ "module" ] [ "loader" ] > ;
141+ /** The data returned from the `action` following an action submission. */
142+ actionData ?: ServerDataFrom < T [ "module" ] [ "action" ] > ;
143+ }
144+ : {
145+ /** The data returned from the `loader` or `clientLoader` */
146+ loaderData ?: T [ "loaderData" ] ;
147+ /** The data returned from the `action` or `clientAction` following an action submission. */
148+ actionData ?: T [ "actionData" ] ;
149+ } ) ;
128150
129151type Match < T extends MatchInfo > = Pretty < {
130152 id : T [ "id" ] ;
@@ -142,7 +164,7 @@ type Matches<T extends Array<MatchInfo>> =
142164 ? [ Match < F > , ...Matches < R > ]
143165 : Array < Match < MatchInfo > | undefined > ;
144166
145- type CreateComponentProps < T extends RouteInfo > = {
167+ type CreateComponentProps < T extends RouteInfo , RSCEnabled extends boolean > = {
146168 /**
147169 * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params } for the current route.
148170 * @example
@@ -158,15 +180,26 @@ type CreateComponentProps<T extends RouteInfo> = {
158180 * }
159181 **/
160182 params : T [ "params" ] ;
161- /** The data returned from the `loader` or `clientLoader` */
162- loaderData : T [ "loaderData" ] ;
163- /** The data returned from the `action` or `clientAction` following an action submission. */
164- actionData ?: T [ "actionData" ] ;
165183 /** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react_router.UIMatch.html route matches}, including parent route matches. */
166184 matches : Matches < T [ "matches" ] > ;
167- } ;
168-
169- type CreateErrorBoundaryProps < T extends RouteInfo > = {
185+ } & ( IsServerFirstRoute < T , RSCEnabled > extends true
186+ ? {
187+ /** The data returned from the `loader` */
188+ loaderData : ServerDataFrom < T [ "module" ] [ "loader" ] > ;
189+ /** The data returned from the `action` following an action submission. */
190+ actionData ?: ServerDataFrom < T [ "module" ] [ "action" ] > ;
191+ }
192+ : {
193+ /** The data returned from the `loader` or `clientLoader` */
194+ loaderData : T [ "loaderData" ] ;
195+ /** The data returned from the `action` or `clientAction` following an action submission. */
196+ actionData ?: T [ "actionData" ] ;
197+ } ) ;
198+
199+ type CreateErrorBoundaryProps <
200+ T extends RouteInfo ,
201+ RSCEnabled extends boolean ,
202+ > = {
170203 /**
171204 * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params } for the current route.
172205 * @example
@@ -183,11 +216,24 @@ type CreateErrorBoundaryProps<T extends RouteInfo> = {
183216 **/
184217 params : T [ "params" ] ;
185218 error : unknown ;
186- loaderData ?: T [ "loaderData" ] ;
187- actionData ?: T [ "actionData" ] ;
188- } ;
189-
190- export type GetAnnotations < Info extends RouteInfo > = {
219+ } & ( IsServerFirstRoute < T , RSCEnabled > extends true
220+ ? {
221+ /** The data returned from the `loader` */
222+ loaderData ?: ServerDataFrom < T [ "module" ] [ "loader" ] > ;
223+ /** The data returned from the `action` following an action submission. */
224+ actionData ?: ServerDataFrom < T [ "module" ] [ "action" ] > ;
225+ }
226+ : {
227+ /** The data returned from the `loader` or `clientLoader` */
228+ loaderData ?: T [ "loaderData" ] ;
229+ /** The data returned from the `action` or `clientAction` following an action submission. */
230+ actionData ?: T [ "actionData" ] ;
231+ } ) ;
232+
233+ export type GetAnnotations <
234+ Info extends RouteInfo ,
235+ RSCEnabled extends boolean ,
236+ > = {
191237 // links
192238 LinkDescriptors : LinkDescriptor [ ] ;
193239 LinksFunction : ( ) => LinkDescriptor [ ] ;
@@ -220,13 +266,13 @@ export type GetAnnotations<Info extends RouteInfo> = {
220266 ClientActionArgs : CreateClientActionArgs < Info > ;
221267
222268 // HydrateFallback
223- HydrateFallbackProps : CreateHydrateFallbackProps < Info > ;
269+ HydrateFallbackProps : CreateHydrateFallbackProps < Info , RSCEnabled > ;
224270
225271 // default (Component)
226- ComponentProps : CreateComponentProps < Info > ;
272+ ComponentProps : CreateComponentProps < Info , RSCEnabled > ;
227273
228274 // ErrorBoundary
229- ErrorBoundaryProps : CreateErrorBoundaryProps < Info > ;
275+ ErrorBoundaryProps : CreateErrorBoundaryProps < Info , RSCEnabled > ;
230276} ;
231277
232278// eslint-disable-next-line @typescript-eslint/no-unused-vars
0 commit comments