@tanstack/react-router 1.32.0 → 1.32.3
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/dist/cjs/Matches.d.cts +6 -9
- package/dist/cjs/RouterProvider.d.cts +6 -6
- package/dist/cjs/awaited.d.cts +1 -1
- package/dist/cjs/defer.d.cts +1 -0
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +38 -79
- package/dist/cjs/index.d.cts +3 -3
- package/dist/cjs/lazyRouteComponent.d.cts +2 -1
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +56 -50
- package/dist/cjs/location.d.cts +3 -2
- package/dist/cjs/not-found.d.cts +2 -2
- package/dist/cjs/path.d.cts +3 -2
- package/dist/cjs/redirects.d.cts +5 -4
- package/dist/cjs/route.cjs +1 -1
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +64 -57
- package/dist/cjs/routeInfo.d.cts +12 -11
- package/dist/cjs/router.cjs +2 -2
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +19 -20
- package/dist/cjs/routerContext.d.cts +1 -1
- package/dist/cjs/scroll-restoration.d.cts +2 -1
- package/dist/cjs/searchParams.d.cts +2 -1
- package/dist/cjs/useBlocker.d.cts +3 -2
- package/dist/cjs/useLocation.d.cts +2 -1
- package/dist/cjs/useNavigate.cjs.map +1 -1
- package/dist/cjs/useNavigate.d.cts +5 -4
- package/dist/cjs/useParams.d.cts +5 -5
- package/dist/cjs/useRouteContext.d.cts +5 -4
- package/dist/cjs/useRouter.d.cts +2 -1
- package/dist/cjs/useRouterState.d.cts +2 -1
- package/dist/cjs/useSearch.d.cts +5 -4
- package/dist/esm/Matches.d.ts +6 -9
- package/dist/esm/RouterProvider.d.ts +6 -6
- package/dist/esm/awaited.d.ts +1 -1
- package/dist/esm/defer.d.ts +1 -0
- package/dist/esm/fileRoute.d.ts +38 -79
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/lazyRouteComponent.d.ts +2 -1
- package/dist/esm/link.d.ts +56 -50
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/location.d.ts +3 -2
- package/dist/esm/not-found.d.ts +2 -2
- package/dist/esm/path.d.ts +3 -2
- package/dist/esm/redirects.d.ts +5 -4
- package/dist/esm/route.d.ts +64 -57
- package/dist/esm/route.js +1 -1
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/routeInfo.d.ts +12 -11
- package/dist/esm/router.d.ts +19 -20
- package/dist/esm/router.js +2 -2
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerContext.d.ts +1 -1
- package/dist/esm/scroll-restoration.d.ts +2 -1
- package/dist/esm/searchParams.d.ts +2 -1
- package/dist/esm/useBlocker.d.ts +3 -2
- package/dist/esm/useLocation.d.ts +2 -1
- package/dist/esm/useNavigate.d.ts +5 -4
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/esm/useParams.d.ts +5 -5
- package/dist/esm/useRouteContext.d.ts +5 -4
- package/dist/esm/useRouter.d.ts +2 -1
- package/dist/esm/useRouterState.d.ts +2 -1
- package/dist/esm/useSearch.d.ts +5 -4
- package/package.json +2 -10
- package/src/fileRoute.ts +26 -104
- package/src/index.tsx +0 -8
- package/src/link.tsx +205 -156
- package/src/route.ts +130 -111
- package/src/routeInfo.ts +24 -22
- package/src/useNavigate.tsx +2 -2
package/src/route.ts
CHANGED
|
@@ -57,16 +57,16 @@ export type RouteOptions<
|
|
|
57
57
|
TParentRoute extends AnyRoute = AnyRoute,
|
|
58
58
|
TCustomId extends string = string,
|
|
59
59
|
TPath extends string = string,
|
|
60
|
-
TSearchSchemaInput
|
|
61
|
-
TSearchSchema
|
|
60
|
+
TSearchSchemaInput = {},
|
|
61
|
+
TSearchSchema = {},
|
|
62
62
|
TSearchSchemaUsed = {},
|
|
63
63
|
TFullSearchSchemaInput = TSearchSchemaUsed,
|
|
64
64
|
TFullSearchSchema = TSearchSchema,
|
|
65
65
|
TParams = AnyPathParams,
|
|
66
66
|
TAllParams = TParams,
|
|
67
|
-
TRouteContextReturn
|
|
67
|
+
TRouteContextReturn = RouteContext,
|
|
68
68
|
TRouteContext = RouteContext,
|
|
69
|
-
TRouterContext
|
|
69
|
+
TRouterContext = AnyContext,
|
|
70
70
|
TAllContext = AnyContext,
|
|
71
71
|
TLoaderDeps extends Record<string, any> = {},
|
|
72
72
|
TLoaderDataReturn = unknown,
|
|
@@ -109,14 +109,14 @@ export type ParamsFallback<
|
|
|
109
109
|
export type FileBaseRouteOptions<
|
|
110
110
|
TParentRoute extends AnyRoute = AnyRoute,
|
|
111
111
|
TPath extends string = string,
|
|
112
|
-
TSearchSchemaInput
|
|
113
|
-
TSearchSchema
|
|
112
|
+
TSearchSchemaInput = {},
|
|
113
|
+
TSearchSchema = {},
|
|
114
114
|
TFullSearchSchema = TSearchSchema,
|
|
115
115
|
TParams = {},
|
|
116
116
|
TAllParams = ParamsFallback<TPath, TParams>,
|
|
117
|
-
TRouteContextReturn
|
|
117
|
+
TRouteContextReturn = RouteContext,
|
|
118
118
|
TRouteContext = RouteContext,
|
|
119
|
-
TRouterContext
|
|
119
|
+
TRouterContext = AnyContext,
|
|
120
120
|
TAllContext = AnyContext,
|
|
121
121
|
TLoaderDeps extends Record<string, any> = {},
|
|
122
122
|
TLoaderDataReturn = unknown,
|
|
@@ -173,16 +173,16 @@ export type BaseRouteOptions<
|
|
|
173
173
|
TParentRoute extends AnyRoute = AnyRoute,
|
|
174
174
|
TCustomId extends string = string,
|
|
175
175
|
TPath extends string = string,
|
|
176
|
-
TSearchSchemaInput
|
|
177
|
-
TSearchSchema
|
|
176
|
+
TSearchSchemaInput = {},
|
|
177
|
+
TSearchSchema = {},
|
|
178
178
|
TSearchSchemaUsed = {},
|
|
179
179
|
TFullSearchSchemaInput = TSearchSchemaUsed,
|
|
180
180
|
TFullSearchSchema = TSearchSchema,
|
|
181
181
|
TParams = {},
|
|
182
182
|
TAllParams = ParamsFallback<TPath, TParams>,
|
|
183
|
-
TRouteContextReturn
|
|
183
|
+
TRouteContextReturn = RouteContext,
|
|
184
184
|
TRouteContext = RouteContext,
|
|
185
|
-
TRouterContext
|
|
185
|
+
TRouterContext = AnyContext,
|
|
186
186
|
TAllContext = AnyContext,
|
|
187
187
|
TLoaderDeps extends Record<string, any> = {},
|
|
188
188
|
TLoaderDataReturn = unknown,
|
|
@@ -209,8 +209,8 @@ type BeforeLoadFn<
|
|
|
209
209
|
in out TFullSearchSchema,
|
|
210
210
|
in out TParentRoute extends AnyRoute,
|
|
211
211
|
in out TAllParams,
|
|
212
|
-
TRouteContextReturn
|
|
213
|
-
in out TRouterContext
|
|
212
|
+
TRouteContextReturn,
|
|
213
|
+
in out TRouterContext = AnyContext,
|
|
214
214
|
in out TContext = IsAny<TParentRoute['types']['allContext'], TRouterContext>,
|
|
215
215
|
> = (opts: {
|
|
216
216
|
search: TFullSearchSchema
|
|
@@ -393,25 +393,54 @@ export type InferFullSearchSchemaInput<TRoute> = TRoute extends {
|
|
|
393
393
|
? TFullSearchSchemaInput
|
|
394
394
|
: {}
|
|
395
395
|
|
|
396
|
+
export type ResolveSearchSchemaUsed<TSearchSchemaInput, TSearchSchema> =
|
|
397
|
+
TSearchSchemaInput extends SearchSchemaInput
|
|
398
|
+
? Omit<TSearchSchemaInput, keyof SearchSchemaInput>
|
|
399
|
+
: TSearchSchema
|
|
400
|
+
|
|
396
401
|
export type ResolveFullSearchSchema<
|
|
397
402
|
TParentRoute extends AnyRoute,
|
|
398
403
|
TSearchSchema,
|
|
399
|
-
> =
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
404
|
+
> = unknown extends TParentRoute
|
|
405
|
+
? Omit<TSearchSchema, keyof RootSearchSchema>
|
|
406
|
+
: Assign<
|
|
407
|
+
TParentRoute['id'] extends RootRouteId
|
|
408
|
+
? Omit<TParentRoute['types']['searchSchema'], keyof RootSearchSchema>
|
|
409
|
+
: TParentRoute['types']['fullSearchSchema'],
|
|
410
|
+
TSearchSchema
|
|
411
|
+
>
|
|
405
412
|
|
|
406
413
|
export type ResolveFullSearchSchemaInput<
|
|
407
414
|
TParentRoute extends AnyRoute,
|
|
408
415
|
TSearchSchemaUsed,
|
|
409
|
-
> =
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
416
|
+
> = unknown extends TParentRoute
|
|
417
|
+
? Omit<TSearchSchemaUsed, keyof RootSearchSchema>
|
|
418
|
+
: Assign<
|
|
419
|
+
TParentRoute['id'] extends RootRouteId
|
|
420
|
+
? Omit<
|
|
421
|
+
TParentRoute['types']['searchSchemaInput'],
|
|
422
|
+
keyof RootSearchSchema
|
|
423
|
+
>
|
|
424
|
+
: TParentRoute['types']['fullSearchSchemaInput'],
|
|
425
|
+
TSearchSchemaUsed
|
|
426
|
+
>
|
|
427
|
+
|
|
428
|
+
export type ResolveRouteContext<TRouteContextReturn> = [
|
|
429
|
+
TRouteContextReturn,
|
|
430
|
+
] extends [never]
|
|
431
|
+
? RouteContext
|
|
432
|
+
: TRouteContextReturn
|
|
433
|
+
|
|
434
|
+
export type ResolveAllContext<
|
|
435
|
+
TParentRoute extends AnyRoute,
|
|
436
|
+
TRouteContext,
|
|
437
|
+
> = Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
|
|
438
|
+
|
|
439
|
+
export type ResolveLoaderData<TLoaderDataReturn> = [TLoaderDataReturn] extends [
|
|
440
|
+
never,
|
|
441
|
+
]
|
|
442
|
+
? undefined
|
|
443
|
+
: TLoaderDataReturn
|
|
415
444
|
|
|
416
445
|
export interface AnyRoute
|
|
417
446
|
extends Route<
|
|
@@ -437,8 +466,12 @@ export interface AnyRoute
|
|
|
437
466
|
any
|
|
438
467
|
> {}
|
|
439
468
|
|
|
440
|
-
|
|
441
|
-
|
|
469
|
+
export type ResolveAllParamsFromParent<
|
|
470
|
+
TParentRoute extends AnyRoute,
|
|
471
|
+
TParams,
|
|
472
|
+
> = unknown extends TParentRoute
|
|
473
|
+
? TParams
|
|
474
|
+
: Assign<TParentRoute['types']['allParams'], TParams>
|
|
442
475
|
|
|
443
476
|
export type ResolveAllParams<TParentRoute extends AnyRoute, TParams> =
|
|
444
477
|
Record<never, string> extends TParentRoute['types']['allParams']
|
|
@@ -465,7 +498,8 @@ export type RouteConstraints = {
|
|
|
465
498
|
|
|
466
499
|
export function getRouteApi<
|
|
467
500
|
TId extends RouteIds<RegisteredRouter['routeTree']>,
|
|
468
|
-
|
|
501
|
+
TRouter extends AnyRouter = RegisteredRouter,
|
|
502
|
+
TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,
|
|
469
503
|
TFullSearchSchema = TRoute['types']['fullSearchSchema'],
|
|
470
504
|
TAllParams = TRoute['types']['allParams'],
|
|
471
505
|
TAllContext = TRoute['types']['allContext'],
|
|
@@ -474,6 +508,7 @@ export function getRouteApi<
|
|
|
474
508
|
>(id: TId) {
|
|
475
509
|
return new RouteApi<
|
|
476
510
|
TId,
|
|
511
|
+
TRouter,
|
|
477
512
|
TRoute,
|
|
478
513
|
TFullSearchSchema,
|
|
479
514
|
TAllParams,
|
|
@@ -485,7 +520,8 @@ export function getRouteApi<
|
|
|
485
520
|
|
|
486
521
|
export class RouteApi<
|
|
487
522
|
TId extends RouteIds<RegisteredRouter['routeTree']>,
|
|
488
|
-
|
|
523
|
+
TRouter extends AnyRouter = RegisteredRouter,
|
|
524
|
+
TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,
|
|
489
525
|
TFullSearchSchema = TRoute['types']['fullSearchSchema'],
|
|
490
526
|
TAllParams = TRoute['types']['allParams'],
|
|
491
527
|
TAllContext = TRoute['types']['allContext'],
|
|
@@ -502,7 +538,7 @@ export class RouteApi<
|
|
|
502
538
|
}
|
|
503
539
|
|
|
504
540
|
useMatch = <
|
|
505
|
-
TRouteTree extends AnyRoute =
|
|
541
|
+
TRouteTree extends AnyRoute = TRouter['routeTree'],
|
|
506
542
|
TRouteMatch = MakeRouteMatch<TRouteTree, TId>,
|
|
507
543
|
TSelected = TRouteMatch,
|
|
508
544
|
>(opts?: {
|
|
@@ -544,7 +580,7 @@ export class RouteApi<
|
|
|
544
580
|
return useLoaderData({ ...opts, from: this.id, strict: false } as any)
|
|
545
581
|
}
|
|
546
582
|
|
|
547
|
-
useNavigate = () => {
|
|
583
|
+
useNavigate = (): UseNavigateResult<TRoute['fullPath']> => {
|
|
548
584
|
return useNavigate({ from: this.id })
|
|
549
585
|
}
|
|
550
586
|
|
|
@@ -566,11 +602,12 @@ export class Route<
|
|
|
566
602
|
TCustomId,
|
|
567
603
|
TPath
|
|
568
604
|
>,
|
|
569
|
-
in out TSearchSchemaInput
|
|
570
|
-
in out TSearchSchema
|
|
571
|
-
in out TSearchSchemaUsed =
|
|
572
|
-
|
|
573
|
-
|
|
605
|
+
in out TSearchSchemaInput = {},
|
|
606
|
+
in out TSearchSchema = {},
|
|
607
|
+
in out TSearchSchemaUsed = ResolveSearchSchemaUsed<
|
|
608
|
+
TSearchSchemaInput,
|
|
609
|
+
TSearchSchema
|
|
610
|
+
>,
|
|
574
611
|
in out TFullSearchSchemaInput = ResolveFullSearchSchemaInput<
|
|
575
612
|
TParentRoute,
|
|
576
613
|
TSearchSchemaUsed
|
|
@@ -581,21 +618,17 @@ export class Route<
|
|
|
581
618
|
>,
|
|
582
619
|
in out TParams = Record<ParsePathParams<TPath>, string>,
|
|
583
620
|
in out TAllParams = ResolveAllParams<TParentRoute, TParams>,
|
|
584
|
-
TRouteContextReturn
|
|
585
|
-
in out TRouteContext =
|
|
586
|
-
? RouteContext
|
|
587
|
-
: TRouteContextReturn,
|
|
621
|
+
TRouteContextReturn = RouteContext,
|
|
622
|
+
in out TRouteContext = ResolveRouteContext<TRouteContextReturn>,
|
|
588
623
|
in out TAllContext = Assign<
|
|
589
624
|
IsAny<TParentRoute['types']['allContext'], {}>,
|
|
590
625
|
TRouteContext
|
|
591
626
|
>,
|
|
592
|
-
in out TRouterContext
|
|
627
|
+
in out TRouterContext = AnyContext,
|
|
593
628
|
in out TLoaderDeps extends Record<string, any> = {},
|
|
594
629
|
TLoaderDataReturn = unknown,
|
|
595
|
-
in out TLoaderData =
|
|
596
|
-
|
|
597
|
-
: TLoaderDataReturn,
|
|
598
|
-
in out TChildren extends RouteConstraints['TChildren'] = unknown,
|
|
630
|
+
in out TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
|
|
631
|
+
in out TChildren = unknown,
|
|
599
632
|
> {
|
|
600
633
|
isRoot: TParentRoute extends Route<any> ? true : false
|
|
601
634
|
options: RouteOptions<
|
|
@@ -764,7 +797,11 @@ export class Route<
|
|
|
764
797
|
this.to = fullPath as TrimPathRight<TFullPath>
|
|
765
798
|
}
|
|
766
799
|
|
|
767
|
-
addChildren = <
|
|
800
|
+
addChildren = <
|
|
801
|
+
const TNewChildren extends
|
|
802
|
+
| Record<string, AnyRoute>
|
|
803
|
+
| ReadonlyArray<AnyRoute>,
|
|
804
|
+
>(
|
|
768
805
|
children: TNewChildren,
|
|
769
806
|
): Route<
|
|
770
807
|
TParentRoute,
|
|
@@ -788,7 +825,9 @@ export class Route<
|
|
|
788
825
|
TLoaderData,
|
|
789
826
|
TNewChildren
|
|
790
827
|
> => {
|
|
791
|
-
this.children =
|
|
828
|
+
this.children = (
|
|
829
|
+
Array.isArray(children) ? children : Object.values(children)
|
|
830
|
+
) as any
|
|
792
831
|
return this as any
|
|
793
832
|
}
|
|
794
833
|
|
|
@@ -846,7 +885,8 @@ export class Route<
|
|
|
846
885
|
}
|
|
847
886
|
|
|
848
887
|
useMatch = <
|
|
849
|
-
|
|
888
|
+
TRouter extends AnyRouter = RegisteredRouter,
|
|
889
|
+
TRouteTree extends AnyRoute = TRouter['routeTree'],
|
|
850
890
|
TRouteMatch = MakeRouteMatch<TRouteTree, TId>,
|
|
851
891
|
TSelected = TRouteMatch,
|
|
852
892
|
>(opts?: {
|
|
@@ -907,11 +947,12 @@ export function createRoute<
|
|
|
907
947
|
TCustomId,
|
|
908
948
|
TPath
|
|
909
949
|
>,
|
|
910
|
-
TSearchSchemaInput
|
|
911
|
-
TSearchSchema
|
|
912
|
-
TSearchSchemaUsed =
|
|
913
|
-
|
|
914
|
-
|
|
950
|
+
TSearchSchemaInput = {},
|
|
951
|
+
TSearchSchema = {},
|
|
952
|
+
TSearchSchemaUsed = ResolveSearchSchemaUsed<
|
|
953
|
+
TSearchSchemaInput,
|
|
954
|
+
TSearchSchema
|
|
955
|
+
>,
|
|
915
956
|
TFullSearchSchemaInput = ResolveFullSearchSchemaInput<
|
|
916
957
|
TParentRoute,
|
|
917
958
|
TSearchSchemaUsed
|
|
@@ -919,21 +960,17 @@ export function createRoute<
|
|
|
919
960
|
TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>,
|
|
920
961
|
TParams = Record<ParsePathParams<TPath>, string>,
|
|
921
962
|
TAllParams = ResolveAllParams<TParentRoute, TParams>,
|
|
922
|
-
TRouteContextReturn
|
|
923
|
-
TRouteContext =
|
|
924
|
-
? RouteContext
|
|
925
|
-
: TRouteContextReturn,
|
|
963
|
+
TRouteContextReturn = RouteContext,
|
|
964
|
+
TRouteContext = ResolveRouteContext<TRouteContextReturn>,
|
|
926
965
|
TAllContext = Assign<
|
|
927
966
|
IsAny<TParentRoute['types']['allContext'], {}>,
|
|
928
967
|
TRouteContext
|
|
929
968
|
>,
|
|
930
|
-
TRouterContext
|
|
969
|
+
TRouterContext = AnyContext,
|
|
931
970
|
TLoaderDeps extends Record<string, any> = {},
|
|
932
971
|
TLoaderDataReturn = unknown,
|
|
933
|
-
TLoaderData =
|
|
934
|
-
|
|
935
|
-
: TLoaderDataReturn,
|
|
936
|
-
TChildren extends RouteConstraints['TChildren'] = unknown,
|
|
972
|
+
TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
|
|
973
|
+
TChildren = unknown,
|
|
937
974
|
>(
|
|
938
975
|
options: RouteOptions<
|
|
939
976
|
TParentRoute,
|
|
@@ -982,19 +1019,15 @@ export function createRoute<
|
|
|
982
1019
|
export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any>
|
|
983
1020
|
|
|
984
1021
|
export type RootRouteOptions<
|
|
985
|
-
TSearchSchemaInput
|
|
986
|
-
TSearchSchema
|
|
987
|
-
TSearchSchemaUsed
|
|
988
|
-
TRouteContextReturn
|
|
989
|
-
TRouteContext
|
|
990
|
-
|
|
991
|
-
: TRouteContextReturn,
|
|
992
|
-
TRouterContext extends {} = {},
|
|
1022
|
+
TSearchSchemaInput = RootSearchSchema,
|
|
1023
|
+
TSearchSchema = RootSearchSchema,
|
|
1024
|
+
TSearchSchemaUsed = RootSearchSchema,
|
|
1025
|
+
TRouteContextReturn = RouteContext,
|
|
1026
|
+
TRouteContext = ResolveRouteContext<TRouteContextReturn>,
|
|
1027
|
+
TRouterContext = {},
|
|
993
1028
|
TLoaderDeps extends Record<string, any> = {},
|
|
994
1029
|
TLoaderDataReturn = unknown,
|
|
995
|
-
TLoaderData =
|
|
996
|
-
? undefined
|
|
997
|
-
: TLoaderDataReturn,
|
|
1030
|
+
TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
|
|
998
1031
|
> = Omit<
|
|
999
1032
|
RouteOptions<
|
|
1000
1033
|
any, // TParentRoute
|
|
@@ -1073,21 +1106,15 @@ export type RootSearchSchema = {
|
|
|
1073
1106
|
}
|
|
1074
1107
|
|
|
1075
1108
|
export class RootRoute<
|
|
1076
|
-
in out TSearchSchemaInput
|
|
1077
|
-
in out TSearchSchema
|
|
1078
|
-
in out TSearchSchemaUsed
|
|
1079
|
-
TRouteContextReturn
|
|
1080
|
-
in out TRouteContext
|
|
1081
|
-
|
|
1082
|
-
]
|
|
1083
|
-
? RouteContext
|
|
1084
|
-
: TRouteContextReturn,
|
|
1085
|
-
in out TRouterContext extends {} = {},
|
|
1109
|
+
in out TSearchSchemaInput = RootSearchSchema,
|
|
1110
|
+
in out TSearchSchema = RootSearchSchema,
|
|
1111
|
+
in out TSearchSchemaUsed = RootSearchSchema,
|
|
1112
|
+
TRouteContextReturn = RouteContext,
|
|
1113
|
+
in out TRouteContext = ResolveRouteContext<TRouteContextReturn>,
|
|
1114
|
+
in out TRouterContext = {},
|
|
1086
1115
|
TLoaderDeps extends Record<string, any> = {},
|
|
1087
1116
|
TLoaderDataReturn = unknown,
|
|
1088
|
-
in out TLoaderData =
|
|
1089
|
-
? undefined
|
|
1090
|
-
: TLoaderDataReturn,
|
|
1117
|
+
in out TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
|
|
1091
1118
|
> extends Route<
|
|
1092
1119
|
any, // TParentRoute
|
|
1093
1120
|
'/', // TPath
|
|
@@ -1131,19 +1158,15 @@ export class RootRoute<
|
|
|
1131
1158
|
}
|
|
1132
1159
|
|
|
1133
1160
|
export function createRootRoute<
|
|
1134
|
-
TSearchSchemaInput
|
|
1135
|
-
TSearchSchema
|
|
1136
|
-
TSearchSchemaUsed
|
|
1137
|
-
TRouteContextReturn
|
|
1138
|
-
TRouteContext
|
|
1139
|
-
|
|
1140
|
-
: TRouteContextReturn,
|
|
1141
|
-
TRouterContext extends {} = {},
|
|
1161
|
+
TSearchSchemaInput = RootSearchSchema,
|
|
1162
|
+
TSearchSchema = RootSearchSchema,
|
|
1163
|
+
TSearchSchemaUsed = RootSearchSchema,
|
|
1164
|
+
TRouteContextReturn = RouteContext,
|
|
1165
|
+
TRouteContext = ResolveRouteContext<TRouteContextReturn>,
|
|
1166
|
+
TRouterContext = {},
|
|
1142
1167
|
TLoaderDeps extends Record<string, any> = {},
|
|
1143
1168
|
TLoaderDataReturn = unknown,
|
|
1144
|
-
TLoaderData =
|
|
1145
|
-
? undefined
|
|
1146
|
-
: TLoaderDataReturn,
|
|
1169
|
+
TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
|
|
1147
1170
|
>(
|
|
1148
1171
|
options?: Omit<
|
|
1149
1172
|
RouteOptions<
|
|
@@ -1276,8 +1299,7 @@ export type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {
|
|
|
1276
1299
|
preload?: () => Promise<void>
|
|
1277
1300
|
}
|
|
1278
1301
|
|
|
1279
|
-
export type RouteComponent<TProps = any> =
|
|
1280
|
-
AsyncRouteComponent<TProps>
|
|
1302
|
+
export type RouteComponent<TProps = any> = AsyncRouteComponent<TProps>
|
|
1281
1303
|
|
|
1282
1304
|
export type ErrorRouteComponent = RouteComponent<ErrorComponentProps>
|
|
1283
1305
|
|
|
@@ -1286,27 +1308,24 @@ export type NotFoundRouteComponent = SyncRouteComponent<NotFoundRouteProps>
|
|
|
1286
1308
|
export class NotFoundRoute<
|
|
1287
1309
|
TParentRoute extends AnyRootRoute,
|
|
1288
1310
|
TSearchSchemaInput extends Record<string, any> = {},
|
|
1289
|
-
TSearchSchema
|
|
1290
|
-
TSearchSchemaUsed
|
|
1291
|
-
TFullSearchSchemaInput
|
|
1292
|
-
RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchemaInput<
|
|
1311
|
+
TSearchSchema = {},
|
|
1312
|
+
TSearchSchemaUsed = {},
|
|
1313
|
+
TFullSearchSchemaInput = ResolveFullSearchSchemaInput<
|
|
1293
1314
|
TParentRoute,
|
|
1294
1315
|
TSearchSchemaUsed
|
|
1295
1316
|
>,
|
|
1296
1317
|
TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>,
|
|
1297
|
-
TRouteContextReturn
|
|
1298
|
-
TRouteContext
|
|
1318
|
+
TRouteContextReturn = AnyContext,
|
|
1319
|
+
TRouteContext = RouteContext,
|
|
1299
1320
|
TAllContext = Assign<
|
|
1300
1321
|
IsAny<TParentRoute['types']['allContext'], {}>,
|
|
1301
1322
|
TRouteContext
|
|
1302
1323
|
>,
|
|
1303
|
-
TRouterContext
|
|
1324
|
+
TRouterContext = AnyContext,
|
|
1304
1325
|
TLoaderDeps extends Record<string, any> = {},
|
|
1305
1326
|
TLoaderDataReturn = unknown,
|
|
1306
|
-
TLoaderData =
|
|
1307
|
-
|
|
1308
|
-
: TLoaderDataReturn,
|
|
1309
|
-
TChildren extends RouteConstraints['TChildren'] = unknown,
|
|
1327
|
+
TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
|
|
1328
|
+
TChildren = unknown,
|
|
1310
1329
|
> extends Route<
|
|
1311
1330
|
TParentRoute,
|
|
1312
1331
|
'/404',
|
package/src/routeInfo.ts
CHANGED
|
@@ -5,19 +5,28 @@ import type { UnionToIntersection, UnionToTuple } from './utils'
|
|
|
5
5
|
export type ParseRoute<TRouteTree, TAcc = TRouteTree> = TRouteTree extends {
|
|
6
6
|
types: { children: infer TChildren }
|
|
7
7
|
}
|
|
8
|
-
?
|
|
9
|
-
?
|
|
10
|
-
:
|
|
8
|
+
? unknown extends TChildren
|
|
9
|
+
? TAcc
|
|
10
|
+
: TChildren extends ReadonlyArray<any>
|
|
11
|
+
? ParseRoute<TChildren[number], TAcc | TChildren[number]>
|
|
12
|
+
: ParseRoute<
|
|
13
|
+
TChildren[keyof TChildren],
|
|
14
|
+
TAcc | TChildren[keyof TChildren]
|
|
15
|
+
>
|
|
11
16
|
: TAcc
|
|
12
17
|
|
|
13
18
|
export type ParseRouteWithoutBranches<TRouteTree> =
|
|
14
19
|
ParseRoute<TRouteTree> extends infer TRoute extends AnyRoute
|
|
15
20
|
? TRoute extends any
|
|
16
|
-
? TRoute['types']['children']
|
|
17
|
-
?
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
? unknown extends TRoute['types']['children']
|
|
22
|
+
? TRoute
|
|
23
|
+
: TRoute['types']['children'] extends ReadonlyArray<any>
|
|
24
|
+
? '/' extends TRoute['types']['children'][number]['path']
|
|
25
|
+
? never
|
|
26
|
+
: TRoute
|
|
27
|
+
: '/' extends TRoute['types']['children'][keyof TRoute['types']['children']]['path']
|
|
28
|
+
? never
|
|
29
|
+
: TRoute
|
|
21
30
|
: never
|
|
22
31
|
: never
|
|
23
32
|
|
|
@@ -32,19 +41,14 @@ export type RouteById<TRouteTree extends AnyRoute, TId> = Extract<
|
|
|
32
41
|
|
|
33
42
|
export type RouteIds<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree>['id']
|
|
34
43
|
|
|
35
|
-
export type CatchAllPaths
|
|
36
|
-
'.' | '..' | '',
|
|
37
|
-
ParseRoute<TRouteTree>
|
|
38
|
-
>
|
|
44
|
+
export type CatchAllPaths = '.' | '..' | ''
|
|
39
45
|
|
|
40
46
|
export type RoutesByPath<TRouteTree extends AnyRoute> = {
|
|
41
47
|
[K in ParseRoute<TRouteTree> as K['fullPath']]: K
|
|
42
|
-
}
|
|
48
|
+
}
|
|
43
49
|
|
|
44
50
|
export type RouteByPath<TRouteTree extends AnyRoute, TPath> = Extract<
|
|
45
|
-
|
|
46
|
-
? ParseRoute<TRouteTree>
|
|
47
|
-
: RoutesByPath<TRouteTree>[TPath],
|
|
51
|
+
RoutesByPath<TRouteTree>[TPath],
|
|
48
52
|
AnyRoute
|
|
49
53
|
>
|
|
50
54
|
|
|
@@ -103,18 +107,16 @@ export type RoutesByToPath<TRouter extends AnyRouter> = {
|
|
|
103
107
|
TRouter,
|
|
104
108
|
TRoute
|
|
105
109
|
>]: TRoute
|
|
106
|
-
}
|
|
110
|
+
}
|
|
107
111
|
|
|
108
112
|
export type RouteByToPath<TRouter extends AnyRouter, TTo> = Extract<
|
|
109
|
-
|
|
110
|
-
? ParseRouteWithoutBranches<TRouter['routeTree']>
|
|
111
|
-
: RoutesByToPath<TRouter>[TTo],
|
|
113
|
+
RoutesByToPath<TRouter>[TTo],
|
|
112
114
|
AnyRoute
|
|
113
115
|
>
|
|
114
116
|
|
|
115
|
-
export type RoutePathsAutoComplete<
|
|
117
|
+
export type RoutePathsAutoComplete<TRouter extends AnyRouter, T> =
|
|
116
118
|
| (string extends T ? T & {} : T)
|
|
117
|
-
| RoutePaths<
|
|
119
|
+
| RoutePaths<TRouter['routeTree']>
|
|
118
120
|
|
|
119
121
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
120
122
|
type UnionizeCollisions<T, U> = {
|
package/src/useNavigate.tsx
CHANGED
|
@@ -20,7 +20,7 @@ export type UseNavigateResult<TDefaultFrom extends string> = <
|
|
|
20
20
|
export function useNavigate<
|
|
21
21
|
TDefaultFrom extends string = string,
|
|
22
22
|
>(_defaultOpts?: {
|
|
23
|
-
from?: RoutePathsAutoComplete<RegisteredRouter
|
|
23
|
+
from?: RoutePathsAutoComplete<RegisteredRouter, TDefaultFrom>
|
|
24
24
|
}): UseNavigateResult<TDefaultFrom> {
|
|
25
25
|
const router = useRouter()
|
|
26
26
|
|
|
@@ -32,7 +32,7 @@ export function useNavigate<
|
|
|
32
32
|
})
|
|
33
33
|
},
|
|
34
34
|
[router],
|
|
35
|
-
)
|
|
35
|
+
) as UseNavigateResult<TDefaultFrom>
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
// NOTE: I don't know of anyone using this. It's undocumented, so let's wait until someone needs it
|