@tanstack/react-router 1.49.7 → 1.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/route.ts CHANGED
@@ -53,13 +53,12 @@ export type RoutePathOptionsIntersection<TCustomId, TPath> = {
53
53
  export type RouteOptions<
54
54
  TParentRoute extends AnyRoute = AnyRoute,
55
55
  TCustomId extends string = string,
56
+ TFullPath extends string = string,
56
57
  TPath extends string = string,
57
- TSearchValidator extends AnySearchValidator = DefaultSearchValidator,
58
+ TSearchValidator = undefined,
58
59
  TParams = AnyPathParams,
59
- TAllParams = TParams,
60
60
  TLoaderDeps extends Record<string, any> = {},
61
- TLoaderDataReturn = {},
62
- TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
61
+ TLoaderFn = undefined,
63
62
  TRouterContext = {},
64
63
  TRouteContextFn = AnyContext,
65
64
  TBeforeLoadFn = AnyContext,
@@ -70,7 +69,7 @@ export type RouteOptions<
70
69
  TSearchValidator,
71
70
  TParams,
72
71
  TLoaderDeps,
73
- TLoaderDataReturn,
72
+ TLoaderFn,
74
73
  TRouterContext,
75
74
  TRouteContextFn,
76
75
  TBeforeLoadFn
@@ -78,9 +77,10 @@ export type RouteOptions<
78
77
  UpdatableRouteOptions<
79
78
  NoInfer<TParentRoute>,
80
79
  NoInfer<TCustomId>,
81
- NoInfer<TAllParams>,
80
+ NoInfer<TFullPath>,
81
+ NoInfer<TParams>,
82
82
  NoInfer<TSearchValidator>,
83
- NoInfer<TLoaderData>,
83
+ NoInfer<TLoaderFn>,
84
84
  NoInfer<TLoaderDeps>,
85
85
  NoInfer<TRouterContext>,
86
86
  NoInfer<TRouteContextFn>,
@@ -131,14 +131,14 @@ export type ParamsOptions<TPath extends string, TParams> = {
131
131
 
132
132
  export interface FullSearchSchemaOption<
133
133
  in out TParentRoute extends AnyRoute,
134
- in out TSearchValidator extends AnySearchValidator,
134
+ in out TSearchValidator,
135
135
  > {
136
136
  search: Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>
137
137
  }
138
138
 
139
139
  export type RouteContextFn<
140
140
  in out TParentRoute extends AnyRoute,
141
- in out TSearchValidator extends AnySearchValidator,
141
+ in out TSearchValidator,
142
142
  in out TParams,
143
143
  in out TRouterContext,
144
144
  > = (
@@ -152,7 +152,7 @@ export type RouteContextFn<
152
152
 
153
153
  export type BeforeLoadFn<
154
154
  in out TParentRoute extends AnyRoute,
155
- in out TSearchValidator extends AnySearchValidator,
155
+ in out TSearchValidator,
156
156
  in out TParams,
157
157
  in out TRouterContext,
158
158
  in out TRouteContextFn,
@@ -169,15 +169,20 @@ export type BeforeLoadFn<
169
169
  export type FileBaseRouteOptions<
170
170
  TParentRoute extends AnyRoute = AnyRoute,
171
171
  TPath extends string = string,
172
- TSearchValidator extends AnySearchValidator = undefined,
172
+ TSearchValidator = undefined,
173
173
  TParams = {},
174
174
  TLoaderDeps extends Record<string, any> = {},
175
- TLoaderDataReturn = {},
175
+ TLoaderFn = undefined,
176
176
  TRouterContext = {},
177
177
  TRouteContextFn = AnyContext,
178
178
  TBeforeLoadFn = AnyContext,
179
179
  > = ParamsOptions<TPath, TParams> & {
180
- validateSearch?: TSearchValidator
180
+ validateSearch?: Constrain<
181
+ TSearchValidator,
182
+ AnySearchValidator,
183
+ DefaultSearchValidator
184
+ >
185
+
181
186
  shouldReload?:
182
187
  | boolean
183
188
  | ((
@@ -193,7 +198,14 @@ export type FileBaseRouteOptions<
193
198
 
194
199
  context?: Constrain<
195
200
  TRouteContextFn,
196
- RouteContextFn<TParentRoute, TSearchValidator, TParams, TRouterContext>
201
+ (
202
+ ctx: RouteContextOptions<
203
+ TParentRoute,
204
+ TSearchValidator,
205
+ TParams,
206
+ TRouterContext
207
+ >,
208
+ ) => any
197
209
  >
198
210
 
199
211
  // This async function is called before a route is loaded.
@@ -202,39 +214,44 @@ export type FileBaseRouteOptions<
202
214
  // If thrown during a preload event, the error will be logged to the console.
203
215
  beforeLoad?: Constrain<
204
216
  TBeforeLoadFn,
205
- BeforeLoadFn<
206
- TParentRoute,
207
- TSearchValidator,
208
- TParams,
209
- TRouterContext,
210
- TRouteContextFn
211
- >
217
+ (
218
+ ctx: BeforeLoadContextOptions<
219
+ TParentRoute,
220
+ TSearchValidator,
221
+ TParams,
222
+ TRouterContext,
223
+ TRouteContextFn
224
+ >,
225
+ ) => any
212
226
  >
213
227
 
214
228
  loaderDeps?: (
215
229
  opts: FullSearchSchemaOption<TParentRoute, TSearchValidator>,
216
230
  ) => TLoaderDeps
217
231
 
218
- loader?: (
219
- ctx: LoaderFnContext<
220
- TParentRoute,
221
- TParams,
222
- TLoaderDeps,
223
- TRouterContext,
224
- TRouteContextFn,
225
- TBeforeLoadFn
226
- >,
227
- ) => TLoaderDataReturn | Promise<TLoaderDataReturn>
232
+ loader?: Constrain<
233
+ TLoaderFn,
234
+ (
235
+ ctx: LoaderFnContext<
236
+ TParentRoute,
237
+ TParams,
238
+ TLoaderDeps,
239
+ TRouterContext,
240
+ TRouteContextFn,
241
+ TBeforeLoadFn
242
+ >,
243
+ ) => any
244
+ >
228
245
  }
229
246
 
230
247
  export type BaseRouteOptions<
231
248
  TParentRoute extends AnyRoute = AnyRoute,
232
249
  TCustomId extends string = string,
233
250
  TPath extends string = string,
234
- TSearchValidator extends AnySearchValidator = undefined,
251
+ TSearchValidator = undefined,
235
252
  TParams = {},
236
253
  TLoaderDeps extends Record<string, any> = {},
237
- TLoaderDataReturn = {},
254
+ TLoaderFn = undefined,
238
255
  TRouterContext = {},
239
256
  TRouteContextFn = AnyContext,
240
257
  TBeforeLoadFn = AnyContext,
@@ -245,7 +262,7 @@ export type BaseRouteOptions<
245
262
  TSearchValidator,
246
263
  TParams,
247
264
  TLoaderDeps,
248
- TLoaderDataReturn,
265
+ TLoaderFn,
249
266
  TRouterContext,
250
267
  TRouteContextFn,
251
268
  TBeforeLoadFn
@@ -255,7 +272,7 @@ export type BaseRouteOptions<
255
272
 
256
273
  export interface ContextOptions<
257
274
  in out TParentRoute extends AnyRoute,
258
- in out TSearchValidator extends AnySearchValidator,
275
+ in out TSearchValidator,
259
276
  in out TParams,
260
277
  > extends FullSearchSchemaOption<TParentRoute, TSearchValidator> {
261
278
  abortController: AbortController
@@ -272,7 +289,7 @@ export interface ContextOptions<
272
289
 
273
290
  export interface RouteContextOptions<
274
291
  in out TParentRoute extends AnyRoute,
275
- in out TSearchValidator extends AnySearchValidator,
292
+ in out TSearchValidator,
276
293
  in out TParams,
277
294
  in out TRouterContext,
278
295
  > extends ContextOptions<TParentRoute, TSearchValidator, TParams> {
@@ -281,7 +298,7 @@ export interface RouteContextOptions<
281
298
 
282
299
  export interface BeforeLoadContextOptions<
283
300
  in out TParentRoute extends AnyRoute,
284
- in out TSearchValidator extends AnySearchValidator,
301
+ in out TSearchValidator,
285
302
  in out TParams,
286
303
  in out TRouterContext,
287
304
  in out TRouteContextFn,
@@ -291,17 +308,18 @@ export interface BeforeLoadContextOptions<
291
308
  >
292
309
  }
293
310
 
294
- export type UpdatableRouteOptions<
295
- TParentRoute extends AnyRoute,
296
- TRouteId,
297
- TAllParams,
298
- TSearchValidator extends AnySearchValidator,
299
- TLoaderData,
300
- TLoaderDeps,
301
- TRouterContext,
302
- TRouteContextFn,
303
- TBeforeLoadFn,
304
- > = {
311
+ export interface UpdatableRouteOptions<
312
+ in out TParentRoute extends AnyRoute,
313
+ in out TRouteId,
314
+ in out TFullPath,
315
+ in out TParams,
316
+ in out TSearchValidator,
317
+ in out TLoaderFn,
318
+ in out TLoaderDeps,
319
+ in out TRouterContext,
320
+ in out TRouteContextFn,
321
+ in out TBeforeLoadFn,
322
+ > extends UpdatableStaticRouteOption {
305
323
  // test?: (args: TAllContext) => void
306
324
  // If true, this route will be matched as case-sensitive
307
325
  caseSensitive?: boolean
@@ -336,9 +354,10 @@ export type UpdatableRouteOptions<
336
354
  onEnter?: (
337
355
  match: RouteMatch<
338
356
  TRouteId,
339
- TAllParams,
357
+ TFullPath,
358
+ ResolveAllParamsFromParent<TParentRoute, TParams>,
340
359
  ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
341
- TLoaderData,
360
+ ResolveLoaderData<TLoaderFn>,
342
361
  ResolveAllContext<
343
362
  TParentRoute,
344
363
  TRouterContext,
@@ -351,9 +370,10 @@ export type UpdatableRouteOptions<
351
370
  onStay?: (
352
371
  match: RouteMatch<
353
372
  TRouteId,
354
- TAllParams,
373
+ TFullPath,
374
+ ResolveAllParamsFromParent<TParentRoute, TParams>,
355
375
  ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
356
- TLoaderData,
376
+ ResolveLoaderData<TLoaderFn>,
357
377
  ResolveAllContext<
358
378
  TParentRoute,
359
379
  TRouterContext,
@@ -366,9 +386,10 @@ export type UpdatableRouteOptions<
366
386
  onLeave?: (
367
387
  match: RouteMatch<
368
388
  TRouteId,
369
- TAllParams,
389
+ TFullPath,
390
+ ResolveAllParamsFromParent<TParentRoute, TParams>,
370
391
  ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
371
- TLoaderData,
392
+ ResolveLoaderData<TLoaderFn>,
372
393
  ResolveAllContext<
373
394
  TParentRoute,
374
395
  TRouterContext,
@@ -382,9 +403,10 @@ export type UpdatableRouteOptions<
382
403
  matches: Array<
383
404
  RouteMatch<
384
405
  TRouteId,
385
- TAllParams,
406
+ TFullPath,
407
+ ResolveAllParamsFromParent<TParentRoute, TParams>,
386
408
  ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
387
- TLoaderData,
409
+ ResolveLoaderData<TLoaderFn>,
388
410
  ResolveAllContext<
389
411
  TParentRoute,
390
412
  TRouterContext,
@@ -396,9 +418,10 @@ export type UpdatableRouteOptions<
396
418
  >
397
419
  match: RouteMatch<
398
420
  TRouteId,
399
- TAllParams,
421
+ TFullPath,
422
+ ResolveAllParamsFromParent<TParentRoute, TParams>,
400
423
  ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
401
- TLoaderData,
424
+ ResolveLoaderData<TLoaderFn>,
402
425
  ResolveAllContext<
403
426
  TParentRoute,
404
427
  TRouterContext,
@@ -407,22 +430,27 @@ export type UpdatableRouteOptions<
407
430
  >,
408
431
  TLoaderDeps
409
432
  >
410
- params: TAllParams
411
- loaderData: TLoaderData
433
+ params: ResolveAllParamsFromParent<TParentRoute, TParams>
434
+ loaderData: ResolveLoaderData<TLoaderFn>
412
435
  }) => Array<React.JSX.IntrinsicElements['meta']>
413
436
  links?: () => Array<React.JSX.IntrinsicElements['link']>
414
437
  scripts?: () => Array<React.JSX.IntrinsicElements['script']>
415
- headers?: (ctx: { loaderData: TLoaderData }) => Record<string, string>
416
- } & UpdatableStaticRouteOption
438
+ headers?: (ctx: {
439
+ loaderData: ResolveLoaderData<TLoaderFn>
440
+ }) => Record<string, string>
441
+ }
417
442
 
418
- export type UpdatableStaticRouteOption =
419
- {} extends PickRequired<StaticDataRouteOption>
420
- ? {
421
- staticData?: StaticDataRouteOption
422
- }
423
- : {
424
- staticData: StaticDataRouteOption
425
- }
443
+ interface RequiredStaticDataRouteOption {
444
+ staticData: StaticDataRouteOption
445
+ }
446
+
447
+ interface OptionalStaticDataRouteOption {
448
+ staticData?: StaticDataRouteOption
449
+ }
450
+
451
+ export type UpdatableStaticRouteOption = {} extends StaticDataRouteOption
452
+ ? OptionalStaticDataRouteOption
453
+ : RequiredStaticDataRouteOption
426
454
 
427
455
  export type MetaDescriptor =
428
456
  | { charSet: 'utf-8' }
@@ -483,7 +511,6 @@ export type RouteLoaderFn<
483
511
  in out TRouterContext = {},
484
512
  in out TRouteContextFn = AnyContext,
485
513
  in out TBeforeLoadFn = AnyContext,
486
- TLoaderData = undefined,
487
514
  > = (
488
515
  match: LoaderFnContext<
489
516
  TParentRoute,
@@ -493,7 +520,7 @@ export type RouteLoaderFn<
493
520
  TRouteContextFn,
494
521
  TBeforeLoadFn
495
522
  >,
496
- ) => TLoaderData | Promise<TLoaderData>
523
+ ) => any
497
524
 
498
525
  export interface LoaderFnContext<
499
526
  in out TParentRoute extends AnyRoute = AnyRoute,
@@ -569,28 +596,27 @@ export type InferAllContext<TRoute> = unknown extends TRoute
569
596
  ? TAllContext
570
597
  : {}
571
598
 
572
- export type ResolveSearchSchemaFnInput<
573
- TSearchValidator extends AnySearchValidator,
574
- > = TSearchValidator extends (input: infer TSearchSchemaInput) => any
575
- ? TSearchSchemaInput extends SearchSchemaInput
576
- ? Omit<TSearchSchemaInput, keyof SearchSchemaInput>
577
- : ResolveSearchSchemaFn<TSearchValidator>
578
- : AnySearchSchema
579
-
580
- export type ResolveSearchSchemaInput<
581
- TSearchValidator extends AnySearchValidator,
582
- > = TSearchValidator extends AnySearchValidatorAdapter
583
- ? TSearchValidator['types']['input']
584
- : TSearchValidator extends AnySearchValidatorObj
585
- ? ResolveSearchSchemaFnInput<TSearchValidator['parse']>
586
- : ResolveSearchSchemaFnInput<TSearchValidator>
587
-
588
- export type ResolveSearchSchemaFn<TSearchValidator extends AnySearchValidator> =
589
- TSearchValidator extends (...args: any) => infer TSearchSchema
590
- ? TSearchSchema
599
+ export type ResolveSearchSchemaFnInput<TSearchValidator> =
600
+ TSearchValidator extends (input: infer TSearchSchemaInput) => any
601
+ ? TSearchSchemaInput extends SearchSchemaInput
602
+ ? Omit<TSearchSchemaInput, keyof SearchSchemaInput>
603
+ : ResolveSearchSchemaFn<TSearchValidator>
591
604
  : AnySearchSchema
592
605
 
593
- export type ResolveSearchSchema<TSearchValidator extends AnySearchValidator> =
606
+ export type ResolveSearchSchemaInput<TSearchValidator> =
607
+ TSearchValidator extends AnySearchValidatorAdapter
608
+ ? TSearchValidator['types']['input']
609
+ : TSearchValidator extends AnySearchValidatorObj
610
+ ? ResolveSearchSchemaFnInput<TSearchValidator['parse']>
611
+ : ResolveSearchSchemaFnInput<TSearchValidator>
612
+
613
+ export type ResolveSearchSchemaFn<TSearchValidator> = TSearchValidator extends (
614
+ ...args: any
615
+ ) => infer TSearchSchema
616
+ ? TSearchSchema
617
+ : AnySearchSchema
618
+
619
+ export type ResolveSearchSchema<TSearchValidator> =
594
620
  unknown extends TSearchValidator
595
621
  ? TSearchValidator
596
622
  : TSearchValidator extends AnySearchValidatorAdapter
@@ -601,7 +627,7 @@ export type ResolveSearchSchema<TSearchValidator extends AnySearchValidator> =
601
627
 
602
628
  export type ResolveFullSearchSchema<
603
629
  TParentRoute extends AnyRoute,
604
- TSearchValidator extends AnySearchValidator,
630
+ TSearchValidator,
605
631
  > = unknown extends TParentRoute
606
632
  ? ResolveSearchSchema<TSearchValidator>
607
633
  : Assign<
@@ -611,7 +637,7 @@ export type ResolveFullSearchSchema<
611
637
 
612
638
  export type ResolveFullSearchSchemaInput<
613
639
  TParentRoute extends AnyRoute,
614
- TSearchValidator extends AnySearchValidator,
640
+ TSearchValidator,
615
641
  > = Assign<
616
642
  InferFullSearchSchemaInput<TParentRoute>,
617
643
  ResolveSearchSchemaInput<TSearchValidator>
@@ -673,11 +699,11 @@ export type ResolveAllContext<
673
699
  ContextAsyncReturnType<TBeforeLoadFn>
674
700
  >
675
701
 
676
- export type ResolveLoaderData<TLoaderDataReturn> = [TLoaderDataReturn] extends [
677
- never,
678
- ]
679
- ? undefined
680
- : TLoaderDataReturn
702
+ export type ResolveLoaderData<TLoaderFn> = unknown extends TLoaderFn
703
+ ? TLoaderFn
704
+ : LooseAsyncReturnType<TLoaderFn> extends never
705
+ ? {}
706
+ : LooseAsyncReturnType<TLoaderFn>
681
707
 
682
708
  export interface AnyRoute
683
709
  extends Route<
@@ -693,8 +719,6 @@ export interface AnyRoute
693
719
  any,
694
720
  any,
695
721
  any,
696
- any,
697
- any,
698
722
  any
699
723
  > {}
700
724
 
@@ -831,28 +855,25 @@ export class Route<
831
855
  TCustomId,
832
856
  TPath
833
857
  >,
834
- in out TSearchValidator extends AnySearchValidator = DefaultSearchValidator,
858
+ in out TSearchValidator = undefined,
835
859
  in out TParams = ResolveParams<TPath>,
836
- in out TAllParams = ResolveAllParamsFromParent<TParentRoute, TParams>,
837
860
  in out TRouterContext = AnyContext,
838
861
  in out TRouteContextFn = AnyContext,
839
862
  in out TBeforeLoadFn = AnyContext,
840
863
  in out TLoaderDeps extends Record<string, any> = {},
841
- TLoaderDataReturn = {},
842
- in out TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
864
+ in out TLoaderFn = undefined,
843
865
  in out TChildren = unknown,
844
866
  > {
845
867
  isRoot: TParentRoute extends Route<any> ? true : false
846
868
  options: RouteOptions<
847
869
  TParentRoute,
848
870
  TCustomId,
871
+ TFullPath,
849
872
  TPath,
850
873
  TSearchValidator,
851
874
  TParams,
852
- TAllParams,
853
875
  TLoaderDeps,
854
- TLoaderDataReturn,
855
- TLoaderData,
876
+ TLoaderFn,
856
877
  TRouterContext,
857
878
  TRouteContextFn,
858
879
  TBeforeLoadFn
@@ -881,13 +902,12 @@ export class Route<
881
902
  options?: RouteOptions<
882
903
  TParentRoute,
883
904
  TCustomId,
905
+ TFullPath,
884
906
  TPath,
885
907
  TSearchValidator,
886
908
  TParams,
887
- TAllParams,
888
909
  TLoaderDeps,
889
- TLoaderDataReturn,
890
- TLoaderData,
910
+ TLoaderFn,
891
911
  TRouterContext,
892
912
  TRouteContextFn,
893
913
  TBeforeLoadFn
@@ -919,7 +939,7 @@ export class Route<
919
939
  TSearchValidator
920
940
  >
921
941
  params: TParams
922
- allParams: TAllParams
942
+ allParams: ResolveAllParamsFromParent<TParentRoute, TParams>
923
943
  routerContext: TRouterContext
924
944
  routeContext: ResolveRouteContext<TRouteContextFn, TBeforeLoadFn>
925
945
  routeContextFn: TRouteContextFn
@@ -931,7 +951,7 @@ export class Route<
931
951
  TBeforeLoadFn
932
952
  >
933
953
  children: TChildren
934
- loaderData: TLoaderData
954
+ loaderData: ResolveLoaderData<TLoaderFn>
935
955
  loaderDeps: TLoaderDeps
936
956
  }
937
957
 
@@ -942,13 +962,12 @@ export class Route<
942
962
  | (RouteOptions<
943
963
  TParentRoute,
944
964
  TCustomId,
965
+ TFullPath,
945
966
  TPath,
946
967
  TSearchValidator,
947
968
  TParams,
948
- TAllParams,
949
969
  TLoaderDeps,
950
- TLoaderDataReturn,
951
- TLoaderData,
970
+ TLoaderFn,
952
971
  TRouterContext,
953
972
  TRouteContextFn,
954
973
  TBeforeLoadFn
@@ -1019,13 +1038,11 @@ export class Route<
1019
1038
  TId,
1020
1039
  TSearchValidator,
1021
1040
  TParams,
1022
- TAllParams,
1023
1041
  TRouterContext,
1024
1042
  TRouteContextFn,
1025
1043
  TBeforeLoadFn,
1026
1044
  TLoaderDeps,
1027
- TLoaderDataReturn,
1028
- TLoaderData,
1045
+ TLoaderFn,
1029
1046
  TNewChildren
1030
1047
  > {
1031
1048
  this.children = (
@@ -1034,15 +1051,17 @@ export class Route<
1034
1051
  return this as any
1035
1052
  }
1036
1053
 
1037
- updateLoader = <TNewLoaderData = unknown>(options: {
1038
- loader: RouteLoaderFn<
1039
- TParentRoute,
1040
- TParams,
1041
- TLoaderDeps,
1042
- TRouterContext,
1043
- TRouteContextFn,
1044
- TBeforeLoadFn,
1045
- TNewLoaderData
1054
+ updateLoader = <TNewLoaderFn>(options: {
1055
+ loader: Constrain<
1056
+ TNewLoaderFn,
1057
+ RouteLoaderFn<
1058
+ TParentRoute,
1059
+ TParams,
1060
+ TLoaderDeps,
1061
+ TRouterContext,
1062
+ TRouteContextFn,
1063
+ TBeforeLoadFn
1064
+ >
1046
1065
  >
1047
1066
  }) => {
1048
1067
  Object.assign(this.options, options)
@@ -1054,12 +1073,11 @@ export class Route<
1054
1073
  TId,
1055
1074
  TSearchValidator,
1056
1075
  TParams,
1057
- TAllParams,
1058
1076
  TRouterContext,
1059
1077
  TRouteContextFn,
1060
1078
  TBeforeLoadFn,
1061
1079
  TLoaderDeps,
1062
- TNewLoaderData,
1080
+ TNewLoaderFn,
1063
1081
  TChildren
1064
1082
  >
1065
1083
  }
@@ -1068,9 +1086,10 @@ export class Route<
1068
1086
  options: UpdatableRouteOptions<
1069
1087
  TParentRoute,
1070
1088
  TCustomId,
1071
- TAllParams,
1089
+ TFullPath,
1090
+ TParams,
1072
1091
  TSearchValidator,
1073
- TLoaderData,
1092
+ TLoaderFn,
1074
1093
  TLoaderDeps,
1075
1094
  TRouterContext,
1076
1095
  TRouteContextFn,
@@ -1135,8 +1154,12 @@ export class Route<
1135
1154
  return useSearch({ ...opts, from: this.id })
1136
1155
  }
1137
1156
 
1138
- useParams = <TSelected = Expand<TAllParams>>(opts?: {
1139
- select?: (search: Expand<TAllParams>) => TSelected
1157
+ useParams = <
1158
+ TSelected = Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>,
1159
+ >(opts?: {
1160
+ select?: (
1161
+ search: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>,
1162
+ ) => TSelected
1140
1163
  }): TSelected => {
1141
1164
  return useParams({ ...opts, from: this.id })
1142
1165
  }
@@ -1147,8 +1170,8 @@ export class Route<
1147
1170
  return useLoaderDeps({ ...opts, from: this.id } as any)
1148
1171
  }
1149
1172
 
1150
- useLoaderData = <TSelected = TLoaderData>(opts?: {
1151
- select?: (search: TLoaderData) => TSelected
1173
+ useLoaderData = <TSelected = ResolveLoaderData<TLoaderFn>>(opts?: {
1174
+ select?: (search: ResolveLoaderData<TLoaderFn>) => TSelected
1152
1175
  }): TSelected => {
1153
1176
  return useLoaderData({ ...opts, from: this.id } as any)
1154
1177
  }
@@ -1171,26 +1194,23 @@ export function createRoute<
1171
1194
  TCustomId,
1172
1195
  TPath
1173
1196
  >,
1174
- TSearchValidator extends AnySearchValidator = DefaultSearchValidator,
1197
+ TSearchValidator = undefined,
1175
1198
  TParams = ResolveParams<TPath>,
1176
- TAllParams = ResolveAllParamsFromParent<TParentRoute, TParams>,
1177
1199
  TRouteContextFn = AnyContext,
1178
1200
  TBeforeLoadFn = AnyContext,
1179
1201
  TLoaderDeps extends Record<string, any> = {},
1180
- TLoaderDataReturn = {},
1181
- TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
1202
+ TLoaderFn = undefined,
1182
1203
  TChildren = unknown,
1183
1204
  >(
1184
1205
  options: RouteOptions<
1185
1206
  TParentRoute,
1186
1207
  TCustomId,
1208
+ TFullPath,
1187
1209
  TPath,
1188
1210
  TSearchValidator,
1189
1211
  TParams,
1190
- TAllParams,
1191
1212
  TLoaderDeps,
1192
- TLoaderDataReturn,
1193
- TLoaderData,
1213
+ TLoaderFn,
1194
1214
  AnyContext,
1195
1215
  TRouteContextFn,
1196
1216
  TBeforeLoadFn
@@ -1204,38 +1224,34 @@ export function createRoute<
1204
1224
  TId,
1205
1225
  TSearchValidator,
1206
1226
  TParams,
1207
- TAllParams,
1208
1227
  AnyContext,
1209
1228
  TRouteContextFn,
1210
1229
  TBeforeLoadFn,
1211
1230
  TLoaderDeps,
1212
- TLoaderDataReturn,
1213
- TLoaderData,
1231
+ TLoaderFn,
1214
1232
  TChildren
1215
1233
  >(options)
1216
1234
  }
1217
1235
 
1218
- export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any>
1236
+ export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any>
1219
1237
 
1220
1238
  export type RootRouteOptions<
1221
- TSearchValidator extends AnySearchValidator = DefaultSearchValidator,
1239
+ TSearchValidator = undefined,
1222
1240
  TRouterContext = {},
1223
1241
  TRouteContextFn = AnyContext,
1224
1242
  TBeforeLoadFn = AnyContext,
1225
1243
  TLoaderDeps extends Record<string, any> = {},
1226
- TLoaderDataReturn = {},
1227
- TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
1244
+ TLoaderFn = undefined,
1228
1245
  > = Omit<
1229
1246
  RouteOptions<
1230
1247
  any, // TParentRoute
1231
- RootRouteId, // TCustomId
1248
+ RootRouteId,
1249
+ '', // TCustomId
1232
1250
  '', // TPath
1233
1251
  TSearchValidator,
1234
1252
  {}, // TParams
1235
- {}, // TAllParams
1236
1253
  TLoaderDeps,
1237
- TLoaderDataReturn, // TLoaderDataReturn,
1238
- TLoaderData, // TLoaderData,
1254
+ TLoaderFn,
1239
1255
  TRouterContext,
1240
1256
  TRouteContextFn,
1241
1257
  TBeforeLoadFn
@@ -1253,10 +1269,9 @@ export function createRootRouteWithContext<TRouterContext extends {}>() {
1253
1269
  return <
1254
1270
  TRouteContextFn = AnyContext,
1255
1271
  TBeforeLoadFn = AnyContext,
1256
- TSearchValidator extends AnySearchValidator = DefaultSearchValidator,
1272
+ TSearchValidator = undefined,
1257
1273
  TLoaderDeps extends Record<string, any> = {},
1258
- TLoaderDataReturn = {},
1259
- TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
1274
+ TLoaderFn = undefined,
1260
1275
  >(
1261
1276
  options?: RootRouteOptions<
1262
1277
  TSearchValidator,
@@ -1264,8 +1279,7 @@ export function createRootRouteWithContext<TRouterContext extends {}>() {
1264
1279
  TRouteContextFn,
1265
1280
  TBeforeLoadFn,
1266
1281
  TLoaderDeps,
1267
- TLoaderDataReturn,
1268
- TLoaderData
1282
+ TLoaderFn
1269
1283
  >,
1270
1284
  ) => {
1271
1285
  return createRootRoute<
@@ -1274,7 +1288,7 @@ export function createRootRouteWithContext<TRouterContext extends {}>() {
1274
1288
  TRouteContextFn,
1275
1289
  TBeforeLoadFn,
1276
1290
  TLoaderDeps,
1277
- TLoaderData
1291
+ TLoaderFn
1278
1292
  >(options as any)
1279
1293
  }
1280
1294
  }
@@ -1285,13 +1299,12 @@ export function createRootRouteWithContext<TRouterContext extends {}>() {
1285
1299
  export const rootRouteWithContext = createRootRouteWithContext
1286
1300
 
1287
1301
  export class RootRoute<
1288
- in out TSearchValidator extends AnySearchValidator = DefaultSearchValidator,
1302
+ in out TSearchValidator = undefined,
1289
1303
  in out TRouterContext = {},
1290
1304
  in out TRouteContextFn = AnyContext,
1291
1305
  in out TBeforeLoadFn = AnyContext,
1292
1306
  TLoaderDeps extends Record<string, any> = {},
1293
- TLoaderDataReturn = {},
1294
- in out TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
1307
+ in out TLoaderFn = undefined,
1295
1308
  TChildren = unknown,
1296
1309
  > extends Route<
1297
1310
  any, // TParentRoute
@@ -1301,13 +1314,11 @@ export class RootRoute<
1301
1314
  RootRouteId, // TId
1302
1315
  TSearchValidator, // TSearchValidator
1303
1316
  {}, // TParams
1304
- {}, // TAllParams
1305
1317
  TRouterContext,
1306
1318
  TRouteContextFn,
1307
1319
  TBeforeLoadFn,
1308
1320
  TLoaderDeps,
1309
- TLoaderDataReturn,
1310
- TLoaderData,
1321
+ TLoaderFn,
1311
1322
  TChildren // TChildren
1312
1323
  > {
1313
1324
  /**
@@ -1320,8 +1331,7 @@ export class RootRoute<
1320
1331
  TRouteContextFn,
1321
1332
  TBeforeLoadFn,
1322
1333
  TLoaderDeps,
1323
- TLoaderDataReturn,
1324
- TLoaderData
1334
+ TLoaderFn
1325
1335
  >,
1326
1336
  ) {
1327
1337
  super(options as any)
@@ -1339,8 +1349,7 @@ export class RootRoute<
1339
1349
  TRouteContextFn,
1340
1350
  TBeforeLoadFn,
1341
1351
  TLoaderDeps,
1342
- TLoaderDataReturn,
1343
- TLoaderData,
1352
+ TLoaderFn,
1344
1353
  TNewChildren
1345
1354
  > {
1346
1355
  return super.addChildren(children)
@@ -1348,13 +1357,12 @@ export class RootRoute<
1348
1357
  }
1349
1358
 
1350
1359
  export function createRootRoute<
1351
- TSearchValidator extends AnySearchValidator = DefaultSearchValidator,
1360
+ TSearchValidator = undefined,
1352
1361
  TRouterContext = {},
1353
1362
  TRouteContextFn = AnyContext,
1354
1363
  TBeforeLoadFn = AnyContext,
1355
1364
  TLoaderDeps extends Record<string, any> = {},
1356
- TLoaderDataReturn = {},
1357
- TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
1365
+ TLoaderFn = undefined,
1358
1366
  >(
1359
1367
  options?: RootRouteOptions<
1360
1368
  TSearchValidator,
@@ -1362,8 +1370,7 @@ export function createRootRoute<
1362
1370
  TRouteContextFn,
1363
1371
  TBeforeLoadFn,
1364
1372
  TLoaderDeps,
1365
- TLoaderDataReturn,
1366
- TLoaderData
1373
+ TLoaderFn
1367
1374
  >,
1368
1375
  ) {
1369
1376
  return new RootRoute<
@@ -1372,8 +1379,7 @@ export function createRootRoute<
1372
1379
  TRouteContextFn,
1373
1380
  TBeforeLoadFn,
1374
1381
  TLoaderDeps,
1375
- TLoaderDataReturn,
1376
- TLoaderData
1382
+ TLoaderFn
1377
1383
  >(options)
1378
1384
  }
1379
1385
 
@@ -1478,10 +1484,9 @@ export class NotFoundRoute<
1478
1484
  TRouterContext = AnyContext,
1479
1485
  TRouteContextFn = AnyContext,
1480
1486
  TBeforeLoadFn = AnyContext,
1481
- TSearchValidator extends AnySearchValidator = DefaultSearchValidator,
1487
+ TSearchValidator = undefined,
1482
1488
  TLoaderDeps extends Record<string, any> = {},
1483
- TLoaderDataReturn = {},
1484
- TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
1489
+ TLoaderFn = undefined,
1485
1490
  TChildren = unknown,
1486
1491
  > extends Route<
1487
1492
  TParentRoute,
@@ -1491,13 +1496,11 @@ export class NotFoundRoute<
1491
1496
  '404',
1492
1497
  TSearchValidator,
1493
1498
  {},
1494
- {},
1495
1499
  TRouterContext,
1496
1500
  TRouteContextFn,
1497
1501
  TBeforeLoadFn,
1498
1502
  TLoaderDeps,
1499
- TLoaderDataReturn,
1500
- TLoaderData,
1503
+ TLoaderFn,
1501
1504
  TChildren
1502
1505
  > {
1503
1506
  constructor(
@@ -1506,12 +1509,11 @@ export class NotFoundRoute<
1506
1509
  TParentRoute,
1507
1510
  string,
1508
1511
  string,
1512
+ string,
1509
1513
  TSearchValidator,
1510
1514
  {},
1511
- {},
1512
1515
  TLoaderDeps,
1513
- TLoaderDataReturn,
1514
- TLoaderData,
1516
+ TLoaderFn,
1515
1517
  TRouterContext,
1516
1518
  TRouteContextFn,
1517
1519
  TBeforeLoadFn