@@ -120,11 +120,33 @@ type CreateClientActionArgs<T extends RouteInfo> = ClientDataFunctionArgs<
120
120
serverAction : ( ) => Promise < ServerDataFrom < T [ "module" ] [ "action" ] > > ;
121
121
} ;
122
122
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
+ > = {
124
136
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
+ } ) ;
128
150
129
151
type Match < T extends MatchInfo > = Pretty < {
130
152
id : T [ "id" ] ;
@@ -142,7 +164,7 @@ type Matches<T extends Array<MatchInfo>> =
142
164
? [ Match < F > , ...Matches < R > ]
143
165
: Array < Match < MatchInfo > | undefined > ;
144
166
145
- type CreateComponentProps < T extends RouteInfo > = {
167
+ type CreateComponentProps < T extends RouteInfo , RSCEnabled extends boolean > = {
146
168
/**
147
169
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params } for the current route.
148
170
* @example
@@ -158,15 +180,26 @@ type CreateComponentProps<T extends RouteInfo> = {
158
180
* }
159
181
**/
160
182
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" ] ;
165
183
/** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react_router.UIMatch.html route matches}, including parent route matches. */
166
184
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
+ > = {
170
203
/**
171
204
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params } for the current route.
172
205
* @example
@@ -183,11 +216,24 @@ type CreateErrorBoundaryProps<T extends RouteInfo> = {
183
216
**/
184
217
params : T [ "params" ] ;
185
218
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
+ > = {
191
237
// links
192
238
LinkDescriptors : LinkDescriptor [ ] ;
193
239
LinksFunction : ( ) => LinkDescriptor [ ] ;
@@ -220,13 +266,13 @@ export type GetAnnotations<Info extends RouteInfo> = {
220
266
ClientActionArgs : CreateClientActionArgs < Info > ;
221
267
222
268
// HydrateFallback
223
- HydrateFallbackProps : CreateHydrateFallbackProps < Info > ;
269
+ HydrateFallbackProps : CreateHydrateFallbackProps < Info , RSCEnabled > ;
224
270
225
271
// default (Component)
226
- ComponentProps : CreateComponentProps < Info > ;
272
+ ComponentProps : CreateComponentProps < Info , RSCEnabled > ;
227
273
228
274
// ErrorBoundary
229
- ErrorBoundaryProps : CreateErrorBoundaryProps < Info > ;
275
+ ErrorBoundaryProps : CreateErrorBoundaryProps < Info , RSCEnabled > ;
230
276
} ;
231
277
232
278
// eslint-disable-next-line @typescript-eslint/no-unused-vars
0 commit comments