@@ -50,20 +50,27 @@ export type ParentParams<TParentParams> = AnyPathParams extends TParentParams
50
50
}
51
51
52
52
export type LoaderFn <
53
- TRouteLoaderData extends AnyLoaderData ,
53
+ TParentRouteLoaderData extends AnyLoaderData = { } ,
54
+ TRouteLoaderData extends AnyLoaderData = { } ,
54
55
TFullSearchSchema extends AnySearchSchema = { } ,
55
56
TAllParams extends AnyPathParams = { } ,
56
57
> = (
57
- loaderContext : LoaderContext < TFullSearchSchema , TAllParams > ,
58
+ loaderContext : LoaderContext <
59
+ TParentRouteLoaderData ,
60
+ TFullSearchSchema ,
61
+ TAllParams
62
+ > ,
58
63
) => Promise < TRouteLoaderData >
59
64
60
65
export interface LoaderContext <
66
+ TParentRouteLoaderData extends AnyLoaderData = { } ,
61
67
TFullSearchSchema extends AnySearchSchema = { } ,
62
68
TAllParams extends AnyPathParams = { } ,
63
69
> {
64
70
params : TAllParams
65
71
search : TFullSearchSchema
66
72
signal ?: AbortSignal
73
+ parentLoaderPromise ?: Promise < TParentRouteLoaderData >
67
74
}
68
75
69
76
export type ActionFn < TActionPayload = unknown , TActionResponse = unknown > = (
@@ -77,6 +84,7 @@ export type UnloaderFn<TPath extends string> = (
77
84
export type RouteOptions <
78
85
TRouteId extends string = string ,
79
86
TPath extends string = string ,
87
+ TParentRouteLoaderData extends AnyLoaderData = { } ,
80
88
TRouteLoaderData extends AnyLoaderData = { } ,
81
89
TLoaderData extends AnyLoaderData = { } ,
82
90
TActionPayload = unknown ,
@@ -109,13 +117,18 @@ export type RouteOptions<
109
117
// calls that match this route.
110
118
postSearchFilters ?: SearchFilter < TFullSearchSchema > [ ]
111
119
// The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`
112
- component ?: GetFrameworkGeneric < 'Component' > // , NoInfer<TLoaderData >>
120
+ component ?: GetFrameworkGeneric < 'Component' > // , NoInfer<TParentLoaderData >>
113
121
// The content to be rendered when the route encounters an error
114
- errorComponent ?: GetFrameworkGeneric < 'Component' > // , NoInfer<TLoaderData >>
122
+ errorComponent ?: GetFrameworkGeneric < 'Component' > // , NoInfer<TParentLoaderData >>
115
123
// If supported by your framework, the content to be rendered as the fallback content until the route is ready to render
116
- pendingComponent ?: GetFrameworkGeneric < 'Component' > //, NoInfer<TLoaderData >>
124
+ pendingComponent ?: GetFrameworkGeneric < 'Component' > //, NoInfer<TParentLoaderData >>
117
125
// An asynchronous function responsible for preparing or fetching data for the route before it is rendered
118
- loader ?: LoaderFn < TRouteLoaderData , TFullSearchSchema , TAllParams >
126
+ loader ?: LoaderFn <
127
+ TParentRouteLoaderData ,
128
+ TRouteLoaderData ,
129
+ TFullSearchSchema ,
130
+ TAllParams
131
+ >
119
132
// The max age to consider loader data fresh (not-stale) for this route in milliseconds from the time of fetch
120
133
// Defaults to 0. Only stale loader data is refetched.
121
134
loaderMaxAge ?: number
@@ -171,6 +184,7 @@ export interface RouteConfig<
171
184
TRouteId extends string = string ,
172
185
TPath extends string = string ,
173
186
TFullPath extends string = string ,
187
+ TParentRouteLoaderData extends AnyLoaderData = AnyLoaderData ,
174
188
TRouteLoaderData extends AnyLoaderData = AnyLoaderData ,
175
189
TLoaderData extends AnyLoaderData = AnyLoaderData ,
176
190
TActionPayload = unknown ,
@@ -193,6 +207,7 @@ export interface RouteConfig<
193
207
options : RouteOptions <
194
208
TRouteId ,
195
209
TPath ,
210
+ TParentRouteLoaderData ,
196
211
TRouteLoaderData ,
197
212
TLoaderData ,
198
213
TActionPayload ,
@@ -217,6 +232,7 @@ export interface RouteConfig<
217
232
TRouteId ,
218
233
TPath ,
219
234
TFullPath ,
235
+ TParentRouteLoaderData ,
220
236
TRouteLoaderData ,
221
237
TLoaderData ,
222
238
TActionPayload ,
@@ -239,6 +255,7 @@ export interface RouteConfig<
239
255
false ,
240
256
TId ,
241
257
TFullPath ,
258
+ TRouteLoaderData ,
242
259
TLoaderData ,
243
260
TFullSearchSchema ,
244
261
TAllParams
@@ -251,6 +268,7 @@ export interface RouteConfig<
251
268
TRouteId ,
252
269
TPath ,
253
270
TFullPath ,
271
+ TParentRouteLoaderData ,
254
272
TRouteLoaderData ,
255
273
TLoaderData ,
256
274
TActionPayload ,
@@ -268,6 +286,7 @@ export interface RouteConfig<
268
286
false ,
269
287
TId ,
270
288
TFullPath ,
289
+ TRouteLoaderData ,
271
290
TLoaderData ,
272
291
TFullSearchSchema ,
273
292
TAllParams
@@ -278,7 +297,8 @@ type CreateRouteConfigFn<
278
297
TIsRoot extends boolean = false ,
279
298
TParentId extends string = string ,
280
299
TParentPath extends string = string ,
281
- TParentAllLoaderData extends AnyLoaderData = { } ,
300
+ TParentRouteLoaderData extends AnyLoaderData = { } ,
301
+ TParentLoaderData extends AnyLoaderData = { } ,
282
302
TParentSearchSchema extends AnySearchSchema = { } ,
283
303
TParentParams extends AnyPathParams = { } ,
284
304
> = <
@@ -309,8 +329,9 @@ type CreateRouteConfigFn<
309
329
RouteOptions <
310
330
TRouteId ,
311
331
TPath ,
332
+ TParentRouteLoaderData ,
312
333
TRouteLoaderData ,
313
- Expand < TParentAllLoaderData & DeepAwaited < NoInfer < TRouteLoaderData > > > ,
334
+ Expand < TParentLoaderData & DeepAwaited < NoInfer < TRouteLoaderData > > > ,
314
335
TActionPayload ,
315
336
TActionResponse ,
316
337
TParentSearchSchema ,
@@ -325,8 +346,9 @@ type CreateRouteConfigFn<
325
346
: RouteOptions <
326
347
TRouteId ,
327
348
TPath ,
349
+ TParentRouteLoaderData ,
328
350
TRouteLoaderData ,
329
- Expand < TParentAllLoaderData & DeepAwaited < NoInfer < TRouteLoaderData > > > ,
351
+ Expand < TParentLoaderData & DeepAwaited < NoInfer < TRouteLoaderData > > > ,
330
352
TActionPayload ,
331
353
TActionResponse ,
332
354
TParentSearchSchema ,
@@ -345,8 +367,9 @@ type CreateRouteConfigFn<
345
367
TResolvedId ,
346
368
TPath ,
347
369
string extends TPath ? '' : RoutePath < RoutePrefix < TParentPath , TPath > > ,
370
+ TParentRouteLoaderData ,
348
371
TRouteLoaderData ,
349
- Expand < TParentAllLoaderData & DeepAwaited < NoInfer < TRouteLoaderData > > > ,
372
+ Expand < TParentLoaderData & DeepAwaited < NoInfer < TRouteLoaderData > > > ,
350
373
TActionPayload ,
351
374
TActionResponse ,
352
375
TParentSearchSchema ,
@@ -389,6 +412,7 @@ export interface AnyRouteConfig
389
412
any ,
390
413
any ,
391
414
any ,
415
+ any ,
392
416
any
393
417
> { }
394
418
@@ -408,6 +432,7 @@ export interface AnyRouteConfigWithChildren<TChildren>
408
432
any ,
409
433
any ,
410
434
any ,
435
+ any ,
411
436
TChildren
412
437
> { }
413
438
0 commit comments