@tanstack/react-router 1.26.11 → 1.26.13

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
@@ -61,13 +61,13 @@ export type RouteOptions<
61
61
  TSearchSchema extends Record<string, any> = {},
62
62
  TSearchSchemaUsed extends Record<string, any> = {},
63
63
  TFullSearchSchemaInput extends Record<string, any> = TSearchSchemaUsed,
64
- TFullSearchSchema extends Record<string, any> = TSearchSchema,
64
+ TFullSearchSchema = TSearchSchema,
65
65
  TParams extends AnyPathParams = AnyPathParams,
66
66
  TAllParams extends AnyPathParams = TParams,
67
67
  TRouteContextReturn extends RouteContext = RouteContext,
68
68
  TRouteContext extends RouteContext = RouteContext,
69
69
  TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,
70
- TAllContext extends Record<string, any> = AnyContext,
70
+ TAllContext = AnyContext,
71
71
  TLoaderDeps extends Record<string, any> = {},
72
72
  TLoaderDataReturn = unknown,
73
73
  TLoaderData = [TLoaderDataReturn] extends [never]
@@ -107,13 +107,13 @@ export type FileBaseRouteOptions<
107
107
  TPath extends string = string,
108
108
  TSearchSchemaInput extends Record<string, any> = {},
109
109
  TSearchSchema extends Record<string, any> = {},
110
- TFullSearchSchema extends Record<string, any> = TSearchSchema,
110
+ TFullSearchSchema = TSearchSchema,
111
111
  TParams extends AnyPathParams = {},
112
112
  TAllParams = ParamsFallback<TPath, TParams>,
113
113
  TRouteContextReturn extends RouteContext = RouteContext,
114
114
  TRouteContext extends RouteContext = RouteContext,
115
115
  TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,
116
- TAllContext extends Record<string, any> = AnyContext,
116
+ TAllContext = AnyContext,
117
117
  TLoaderDeps extends Record<string, any> = {},
118
118
  TLoaderDataReturn = unknown,
119
119
  > = {
@@ -173,13 +173,13 @@ export type BaseRouteOptions<
173
173
  TSearchSchema extends Record<string, any> = {},
174
174
  TSearchSchemaUsed extends Record<string, any> = {},
175
175
  TFullSearchSchemaInput extends Record<string, any> = TSearchSchemaUsed,
176
- TFullSearchSchema extends Record<string, any> = TSearchSchema,
176
+ TFullSearchSchema = TSearchSchema,
177
177
  TParams extends AnyPathParams = {},
178
178
  TAllParams = ParamsFallback<TPath, TParams>,
179
179
  TRouteContextReturn extends RouteContext = RouteContext,
180
180
  TRouteContext extends RouteContext = RouteContext,
181
181
  TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,
182
- TAllContext extends Record<string, any> = AnyContext,
182
+ TAllContext = AnyContext,
183
183
  TLoaderDeps extends Record<string, any> = {},
184
184
  TLoaderDataReturn = unknown,
185
185
  > = RoutePathOptions<TCustomId, TPath> &
@@ -202,7 +202,7 @@ export type BaseRouteOptions<
202
202
  }
203
203
 
204
204
  type BeforeLoadFn<
205
- TFullSearchSchema extends Record<string, any>,
205
+ TFullSearchSchema,
206
206
  TParentRoute extends AnyRoute,
207
207
  TAllParams,
208
208
  TRouteContextReturn extends RouteContext,
@@ -222,7 +222,7 @@ type BeforeLoadFn<
222
222
 
223
223
  export type UpdatableRouteOptions<
224
224
  TAllParams extends Record<string, any>,
225
- TFullSearchSchema extends Record<string, any>,
225
+ TFullSearchSchema,
226
226
  TLoaderData,
227
227
  > = {
228
228
  // test?: (args: TAllContext) => void
@@ -325,7 +325,7 @@ export type SearchSchemaValidatorFn<TInput, TReturn> = (
325
325
  export type RouteLoaderFn<
326
326
  TAllParams = {},
327
327
  TLoaderDeps extends Record<string, any> = {},
328
- TAllContext extends Record<string, any> = AnyContext,
328
+ TAllContext = AnyContext,
329
329
  TRouteContext extends Record<string, any> = AnyContext,
330
330
  TLoaderData = unknown,
331
331
  > = (
@@ -334,8 +334,8 @@ export type RouteLoaderFn<
334
334
 
335
335
  export interface LoaderFnContext<
336
336
  TAllParams = {},
337
- TLoaderDeps extends Record<string, any> = {},
338
- TAllContext extends Record<string, any> = AnyContext,
337
+ TLoaderDeps = {},
338
+ TAllContext = AnyContext,
339
339
  TRouteContext extends Record<string, any> = AnyContext,
340
340
  > {
341
341
  abortController: AbortController
@@ -376,20 +376,27 @@ export type InferFullSearchSchemaInput<TRoute> = TRoute extends {
376
376
  ? TFullSearchSchemaInput
377
377
  : {}
378
378
 
379
- export type ResolveFullSearchSchema<TParentRoute, TSearchSchema> = Expand<
380
- Assign<
381
- Omit<InferFullSearchSchema<TParentRoute>, keyof RootSearchSchema>,
382
- TSearchSchema
383
- >
379
+ export type ResolveFullSearchSchema<
380
+ TParentRoute extends AnyRoute,
381
+ TSearchSchema,
382
+ > = Assign<
383
+ TParentRoute['isRoot'] extends true
384
+ ? TParentRoute['types']['searchSchema']
385
+ : TParentRoute['types']['fullSearchSchema'],
386
+ TSearchSchema,
387
+ keyof RootSearchSchema
384
388
  >
385
389
 
386
- export type ResolveFullSearchSchemaInput<TParentRoute, TSearchSchemaUsed> =
387
- Expand<
388
- Assign<
389
- Omit<InferFullSearchSchemaInput<TParentRoute>, keyof RootSearchSchema>,
390
- TSearchSchemaUsed
391
- >
392
- >
390
+ export type ResolveFullSearchSchemaInput<
391
+ TParentRoute extends AnyRoute,
392
+ TSearchSchemaUsed,
393
+ > = Assign<
394
+ TParentRoute['isRoot'] extends true
395
+ ? TParentRoute['types']['searchSchemaInput']
396
+ : TParentRoute['types']['fullSearchSchemaInput'],
397
+ TSearchSchemaUsed,
398
+ keyof RootSearchSchema
399
+ >
393
400
 
394
401
  export interface AnyRoute
395
402
  extends Route<
@@ -450,12 +457,9 @@ export type RouteConstraints = {
450
457
  export function getRouteApi<
451
458
  TId extends RouteIds<RegisteredRouter['routeTree']>,
452
459
  TRoute extends AnyRoute = RouteById<RegisteredRouter['routeTree'], TId>,
453
- TFullSearchSchema extends Record<
454
- string,
455
- any
456
- > = TRoute['types']['fullSearchSchema'],
460
+ TFullSearchSchema = TRoute['types']['fullSearchSchema'],
457
461
  TAllParams extends AnyPathParams = TRoute['types']['allParams'],
458
- TAllContext extends Record<string, any> = TRoute['types']['allContext'],
462
+ TAllContext = TRoute['types']['allContext'],
459
463
  TLoaderDeps extends Record<string, any> = TRoute['types']['loaderDeps'],
460
464
  TLoaderData = TRoute['types']['loaderData'],
461
465
  >(id: TId) {
@@ -473,12 +477,9 @@ export function getRouteApi<
473
477
  export class RouteApi<
474
478
  TId extends RouteIds<RegisteredRouter['routeTree']>,
475
479
  TRoute extends AnyRoute = RouteById<RegisteredRouter['routeTree'], TId>,
476
- TFullSearchSchema extends Record<
477
- string,
478
- any
479
- > = TRoute['types']['fullSearchSchema'],
480
+ TFullSearchSchema = TRoute['types']['fullSearchSchema'],
480
481
  TAllParams extends AnyPathParams = TRoute['types']['allParams'],
481
- TAllContext extends Record<string, any> = TRoute['types']['allContext'],
482
+ TAllContext = TRoute['types']['allContext'],
482
483
  TLoaderDeps extends Record<string, any> = TRoute['types']['loaderDeps'],
483
484
  TLoaderData = TRoute['types']['loaderData'],
484
485
  > {
@@ -568,11 +569,7 @@ export class Route<
568
569
  string,
569
570
  any
570
571
  > = ResolveFullSearchSchemaInput<TParentRoute, TSearchSchemaUsed>,
571
- TFullSearchSchema extends
572
- RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<
573
- TParentRoute,
574
- TSearchSchema
575
- >,
572
+ TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>,
576
573
  TParams extends RouteConstraints['TParams'] = Expand<
577
574
  Record<ParsePathParams<TPath>, string>
578
575
  >,
@@ -586,9 +583,7 @@ export class Route<
586
583
  ] extends [never]
587
584
  ? RouteContext
588
585
  : TRouteContextReturn,
589
- in out TAllContext extends Expand<
590
- Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
591
- > = Expand<
586
+ in out TAllContext = Expand<
592
587
  Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
593
588
  >,
594
589
  TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,
@@ -918,11 +913,7 @@ export function createRoute<
918
913
  string,
919
914
  any
920
915
  > = ResolveFullSearchSchemaInput<TParentRoute, TSearchSchemaUsed>,
921
- TFullSearchSchema extends
922
- RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<
923
- TParentRoute,
924
- TSearchSchema
925
- >,
916
+ TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>,
926
917
  TParams extends RouteConstraints['TParams'] = Expand<
927
918
  Record<ParsePathParams<TPath>, string>
928
919
  >,
@@ -936,9 +927,7 @@ export function createRoute<
936
927
  ] extends [never]
937
928
  ? RouteContext
938
929
  : TRouteContextReturn,
939
- TAllContext extends Expand<
940
- Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
941
- > = Expand<
930
+ TAllContext = Expand<
942
931
  Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
943
932
  >,
944
933
  TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,
@@ -1091,7 +1080,7 @@ export class RootRoute<
1091
1080
  {}, // TAllParams
1092
1081
  TRouteContextReturn, // TRouteContextReturn
1093
1082
  TRouteContext, // TRouteContext
1094
- Expand<Assign<TRouterContext, TRouteContext>>, // TAllContext
1083
+ Assign<TRouterContext, TRouteContext>, // TAllContext
1095
1084
  TRouterContext, // TRouterContext
1096
1085
  TLoaderDeps,
1097
1086
  TLoaderDataReturn,
@@ -1298,16 +1287,10 @@ export class NotFoundRoute<
1298
1287
  TParentRoute,
1299
1288
  TSearchSchemaUsed
1300
1289
  >,
1301
- TFullSearchSchema extends
1302
- RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<
1303
- TParentRoute,
1304
- TSearchSchema
1305
- >,
1290
+ TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>,
1306
1291
  TRouteContextReturn extends RouteConstraints['TRouteContext'] = AnyContext,
1307
1292
  TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext,
1308
- TAllContext extends Expand<
1309
- Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
1310
- > = Expand<
1293
+ TAllContext = Expand<
1311
1294
  Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
1312
1295
  >,
1313
1296
  TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,
package/src/utils.ts CHANGED
@@ -49,7 +49,13 @@ export type IsUnion<T, U extends T = T> = (
49
49
  ? false
50
50
  : true
51
51
 
52
- export type Assign<TLeft, TRight> = Omit<TLeft, keyof TRight> & TRight
52
+ export type Assign<TLeft, TRight, TExclude = never> = {
53
+ [K in Exclude<keyof TLeft | keyof TRight, TExclude>]: K extends keyof TRight
54
+ ? TRight[K]
55
+ : K extends keyof TLeft
56
+ ? TLeft[K]
57
+ : never
58
+ }
53
59
 
54
60
  export type Timeout = ReturnType<typeof setTimeout>
55
61