@tanstack/router-core 0.0.1-beta.191 → 0.0.1-beta.193

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/router-core",
3
3
  "author": "Tanner Linsley",
4
- "version": "0.0.1-beta.191",
4
+ "version": "0.0.1-beta.193",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router",
package/src/fileRoute.ts CHANGED
@@ -85,6 +85,7 @@ export class FileRoute<
85
85
  constructor(public path: TFilePath) {}
86
86
 
87
87
  createRoute = <
88
+ TLoaderContext extends RouteConstraints['TLoaderContext'] = {},
88
89
  TLoader = unknown,
89
90
  TSearchSchema extends RouteConstraints['TSearchSchema'] = {},
90
91
  TFullSearchSchema extends RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<
@@ -99,7 +100,7 @@ export class FileRoute<
99
100
  TParams
100
101
  >,
101
102
  TParentContext extends RouteConstraints['TParentContext'] = TParentRoute['types']['routeContext'],
102
- TAllParentContext extends RouteConstraints['TId'] = TParentRoute['types']['context'],
103
+ TAllParentContext extends RouteConstraints['TAllParentContext'] = TParentRoute['types']['context'],
103
104
  TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext,
104
105
  TContext extends RouteConstraints['TAllContext'] = MergeFromFromParent<
105
106
  TParentRoute['types']['context'],
@@ -114,8 +115,8 @@ export class FileRoute<
114
115
  TParentRoute,
115
116
  string,
116
117
  string,
118
+ TLoaderContext,
117
119
  TLoader,
118
- InferFullSearchSchema<TParentRoute>,
119
120
  TSearchSchema,
120
121
  TFullSearchSchema,
121
122
  TParams,
@@ -141,6 +142,7 @@ export class FileRoute<
141
142
  TFullPath,
142
143
  TFilePath,
143
144
  TId,
145
+ TLoaderContext,
144
146
  TLoader,
145
147
  TSearchSchema,
146
148
  TFullSearchSchema,
package/src/link.ts CHANGED
@@ -1,7 +1,13 @@
1
1
  import { Trim } from './fileRoute'
2
2
  import { AnyRoute } from './route'
3
- import { AllParams, RouteByPath, RouteIds, RoutePaths } from './routeInfo'
4
- import { LocationState, ParsedLocation } from './router'
3
+ import {
4
+ AllParams,
5
+ FullSearchSchema,
6
+ RouteByPath,
7
+ RouteIds,
8
+ RoutePaths,
9
+ } from './routeInfo'
10
+ import { LocationState, ParsedLocation, RegisteredRouter } from './router'
5
11
  import {
6
12
  Expand,
7
13
  NoInfer,
@@ -119,7 +125,7 @@ export type RelativeToPathAutoComplete<
119
125
  | AllPaths
120
126
 
121
127
  export type NavigateOptions<
122
- TRouteTree extends AnyRoute = AnyRoute,
128
+ TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
123
129
  TFrom extends RoutePaths<TRouteTree> = '/',
124
130
  TTo extends string = '',
125
131
  TMaskFrom extends RoutePaths<TRouteTree> = TFrom,
@@ -131,7 +137,7 @@ export type NavigateOptions<
131
137
  }
132
138
 
133
139
  export type ToOptions<
134
- TRouteTree extends AnyRoute = AnyRoute,
140
+ TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
135
141
  TFrom extends RoutePaths<TRouteTree> = '/',
136
142
  TTo extends string = '',
137
143
  TMaskFrom extends RoutePaths<TRouteTree> = '/',
@@ -141,7 +147,7 @@ export type ToOptions<
141
147
  }
142
148
 
143
149
  export type ToMaskOptions<
144
- TRouteTree extends AnyRoute = AnyRoute,
150
+ TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
145
151
  TMaskFrom extends RoutePaths<TRouteTree> = '/',
146
152
  TMaskTo extends string = '',
147
153
  > = ToSubOptions<TRouteTree, TMaskFrom, TMaskTo> & {
@@ -149,7 +155,7 @@ export type ToMaskOptions<
149
155
  }
150
156
 
151
157
  export type ToSubOptions<
152
- TRouteTree extends AnyRoute = AnyRoute,
158
+ TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
153
159
  TFrom extends RoutePaths<TRouteTree> = '/',
154
160
  TTo extends string = '',
155
161
  TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>,
@@ -164,21 +170,28 @@ export type ToSubOptions<
164
170
  // // When using relative route paths, this option forces resolution from the current path, instead of the route API's path or `from` path
165
171
  // fromCurrent?: boolean
166
172
  } & CheckPath<TRouteTree, NoInfer<TResolved>, {}> &
167
- SearchParamOptions<TRouteTree, TFrom, TResolved> &
173
+ SearchParamOptions<TRouteTree, TFrom, TTo, TResolved> &
168
174
  PathParamOptions<TRouteTree, TFrom, TResolved>
169
175
 
170
176
  export type SearchParamOptions<
171
177
  TRouteTree extends AnyRoute,
172
178
  TFrom,
173
179
  TTo,
174
- TFromSearchEnsured = Expand<
175
- UnionToIntersection<
176
- PickRequired<RouteByPath<TRouteTree, TFrom>['types']['fullSearchSchema']>
177
- >
178
- >,
180
+ TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>,
181
+ TFromSearchEnsured = '/' extends TFrom
182
+ ? FullSearchSchema<TRouteTree>
183
+ : Expand<
184
+ UnionToIntersection<
185
+ PickRequired<
186
+ RouteByPath<TRouteTree, TFrom>['types']['fullSearchSchema']
187
+ >
188
+ >
189
+ >,
179
190
  TFromSearchOptional = Omit<AllParams<TRouteTree>, keyof TFromSearchEnsured>,
180
191
  TFromSearch = Expand<TFromSearchEnsured & TFromSearchOptional>,
181
- TToSearch = Expand<RouteByPath<TRouteTree, TTo>['types']['fullSearchSchema']>,
192
+ TToSearch = '' extends TTo
193
+ ? FullSearchSchema<TRouteTree>
194
+ : Expand<RouteByPath<TRouteTree, TResolved>['types']['fullSearchSchema']>,
182
195
  > = keyof PickRequired<TToSearch> extends never
183
196
  ? {
184
197
  search?: true | SearchReducer<TFromSearch, TToSearch>
@@ -246,7 +259,7 @@ export interface ActiveOptions {
246
259
  }
247
260
 
248
261
  export type LinkOptions<
249
- TRouteTree extends AnyRoute = AnyRoute,
262
+ TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
250
263
  TFrom extends RoutePaths<TRouteTree> = '/',
251
264
  TTo extends string = '',
252
265
  TMaskFrom extends RoutePaths<TRouteTree> = TFrom,
package/src/route.ts CHANGED
@@ -3,6 +3,8 @@ import { RoutePaths } from './routeInfo'
3
3
  import { joinPaths, trimPath } from './path'
4
4
  import { AnyRouter, RouteMatch, AnyRouteMatch } from './router'
5
5
  import {
6
+ DeepMerge,
7
+ DeepMergeAll,
6
8
  Expand,
7
9
  IsAny,
8
10
  NoInfer,
@@ -20,63 +22,63 @@ export interface RouteMeta {}
20
22
  export interface RouteContext {}
21
23
  export interface RegisterRouteComponent<
22
24
  TLoader = unknown,
23
- TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
25
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
24
26
  TAllParams extends AnyPathParams = AnyPathParams,
25
- TRouteContext extends AnyContext = AnyContext,
26
- TAllContext extends AnyContext = AnyContext,
27
+ TRouteContext extends Record<string, any> = AnyContext,
28
+ TAllContext extends Record<string, any> = AnyContext,
27
29
  > {
28
30
  // RouteComponent: unknown // This is registered by the framework
29
31
  }
30
32
  export interface RegisterErrorRouteComponent<
31
- TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
33
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
32
34
  TAllParams extends AnyPathParams = AnyPathParams,
33
- TRouteContext extends AnyContext = AnyContext,
34
- TAllContext extends AnyContext = AnyContext,
35
+ TRouteContext extends Record<string, any> = AnyContext,
36
+ TAllContext extends Record<string, any> = AnyContext,
35
37
  > {
36
38
  // ErrorRouteComponent: unknown // This is registered by the framework
37
39
  }
38
40
  export interface RegisterPendingRouteComponent<
39
- TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
41
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
40
42
  TAllParams extends AnyPathParams = AnyPathParams,
41
- TRouteContext extends AnyContext = AnyContext,
42
- TAllContext extends AnyContext = AnyContext,
43
+ TRouteContext extends Record<string, any> = AnyContext,
44
+ TAllContext extends Record<string, any> = AnyContext,
43
45
  > {
44
46
  // PendingRouteComponent: unknown // This is registered by the framework
45
47
  }
46
48
 
47
49
  export interface RegisterRouteProps<
48
50
  TLoader = unknown,
49
- TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
51
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
50
52
  TAllParams extends AnyPathParams = AnyPathParams,
51
- TRouteContext extends AnyContext = AnyContext,
52
- TAllContext extends AnyContext = AnyContext,
53
+ TRouteContext extends Record<string, any> = AnyContext,
54
+ TAllContext extends Record<string, any> = AnyContext,
53
55
  > {
54
56
  // RouteProps: unknown // This is registered by the framework
55
57
  }
56
58
  export interface RegisterErrorRouteProps<
57
- TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
59
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
58
60
  TAllParams extends AnyPathParams = AnyPathParams,
59
- TRouteContext extends AnyContext = AnyContext,
60
- TAllContext extends AnyContext = AnyContext,
61
+ TRouteContext extends Record<string, any> = AnyContext,
62
+ TAllContext extends Record<string, any> = AnyContext,
61
63
  > {
62
64
  // ErrorRouteProps: unknown // This is registered by the framework
63
65
  }
64
66
 
65
67
  export interface RegisterPendingRouteProps<
66
- TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
68
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
67
69
  TAllParams extends AnyPathParams = AnyPathParams,
68
- TRouteContext extends AnyContext = AnyContext,
69
- TAllContext extends AnyContext = AnyContext,
70
+ TRouteContext extends Record<string, any> = AnyContext,
71
+ TAllContext extends Record<string, any> = AnyContext,
70
72
  > {
71
73
  // PendingRouteProps: unknown // This is registered by the framework
72
74
  }
73
75
 
74
76
  export type RegisteredRouteComponent<
75
77
  TLoader = unknown,
76
- TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
78
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
77
79
  TAllParams extends AnyPathParams = AnyPathParams,
78
- TRouteContext extends AnyContext = AnyContext,
79
- TAllContext extends AnyContext = AnyContext,
80
+ TRouteContext extends Record<string, any> = AnyContext,
81
+ TAllContext extends Record<string, any> = AnyContext,
80
82
  > = RegisterRouteComponent<
81
83
  TLoader,
82
84
  TFullSearchSchema,
@@ -90,10 +92,10 @@ export type RegisteredRouteComponent<
90
92
  : () => unknown
91
93
 
92
94
  export type RegisteredErrorRouteComponent<
93
- TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
95
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
94
96
  TAllParams extends AnyPathParams = AnyPathParams,
95
- TRouteContext extends AnyContext = AnyContext,
96
- TAllContext extends AnyContext = AnyContext,
97
+ TRouteContext extends Record<string, any> = AnyContext,
98
+ TAllContext extends Record<string, any> = AnyContext,
97
99
  > = RegisterErrorRouteComponent<
98
100
  TFullSearchSchema,
99
101
  TAllParams,
@@ -106,10 +108,10 @@ export type RegisteredErrorRouteComponent<
106
108
  : () => unknown
107
109
 
108
110
  export type RegisteredPendingRouteComponent<
109
- TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
111
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
110
112
  TAllParams extends AnyPathParams = AnyPathParams,
111
- TRouteContext extends AnyContext = AnyContext,
112
- TAllContext extends AnyContext = AnyContext,
113
+ TRouteContext extends Record<string, any> = AnyContext,
114
+ TAllContext extends Record<string, any> = AnyContext,
113
115
  > = RegisterPendingRouteComponent<
114
116
  TFullSearchSchema,
115
117
  TAllParams,
@@ -123,10 +125,10 @@ export type RegisteredPendingRouteComponent<
123
125
 
124
126
  export type RegisteredRouteProps<
125
127
  TLoader = unknown,
126
- TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
128
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
127
129
  TAllParams extends AnyPathParams = AnyPathParams,
128
- TRouteContext extends AnyContext = AnyContext,
129
- TAllContext extends AnyContext = AnyContext,
130
+ TRouteContext extends Record<string, any> = AnyContext,
131
+ TAllContext extends Record<string, any> = AnyContext,
130
132
  > = RegisterRouteProps<
131
133
  TLoader,
132
134
  TFullSearchSchema,
@@ -140,10 +142,10 @@ export type RegisteredRouteProps<
140
142
  : {}
141
143
 
142
144
  export type RegisteredErrorRouteProps<
143
- TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
145
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
144
146
  TAllParams extends AnyPathParams = AnyPathParams,
145
- TRouteContext extends AnyContext = AnyContext,
146
- TAllContext extends AnyContext = AnyContext,
147
+ TRouteContext extends Record<string, any> = AnyContext,
148
+ TAllContext extends Record<string, any> = AnyContext,
147
149
  > = RegisterRouteProps<
148
150
  TFullSearchSchema,
149
151
  TAllParams,
@@ -156,10 +158,10 @@ export type RegisteredErrorRouteProps<
156
158
  : {}
157
159
 
158
160
  export type RegisteredPendingRouteProps<
159
- TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
161
+ TFullSearchSchema extends Record<string, any> = AnySearchSchema,
160
162
  TAllParams extends AnyPathParams = AnyPathParams,
161
- TRouteContext extends AnyContext = AnyContext,
162
- TAllContext extends AnyContext = AnyContext,
163
+ TRouteContext extends Record<string, any> = AnyContext,
164
+ TAllContext extends Record<string, any> = AnyContext,
163
165
  > = RegisterRouteProps<
164
166
  TFullSearchSchema,
165
167
  TAllParams,
@@ -198,22 +200,22 @@ export type RouteOptions<
198
200
  TParentRoute extends AnyRoute = AnyRoute,
199
201
  TCustomId extends string = string,
200
202
  TPath extends string = string,
203
+ TLoaderContext extends Record<string, any> = AnyContext,
201
204
  TLoader = unknown,
202
- TParentSearchSchema extends AnySearchSchema = {},
203
- TSearchSchema extends AnySearchSchema = {},
204
- TFullSearchSchema extends AnySearchSchema = TSearchSchema,
205
+ TSearchSchema extends Record<string, any> = {},
206
+ TFullSearchSchema extends Record<string, any> = TSearchSchema,
205
207
  TParams extends AnyPathParams = AnyPathParams,
206
208
  TAllParams extends AnyPathParams = TParams,
207
- TParentContext extends AnyContext = AnyContext,
208
- TAllParentContext extends AnyContext = AnyContext,
209
+ TParentContext extends Record<string, any> = AnyContext,
210
+ TAllParentContext extends Record<string, any> = AnyContext,
209
211
  TRouteContext extends RouteContext = RouteContext,
210
- TAllContext extends AnyContext = AnyContext,
212
+ TAllContext extends Record<string, any> = AnyContext,
211
213
  > = BaseRouteOptions<
212
214
  TParentRoute,
213
215
  TCustomId,
214
216
  TPath,
217
+ TLoaderContext,
215
218
  TLoader,
216
- TParentSearchSchema,
217
219
  TSearchSchema,
218
220
  TFullSearchSchema,
219
221
  TParams,
@@ -245,27 +247,20 @@ export type BaseRouteOptions<
245
247
  TParentRoute extends AnyRoute = AnyRoute,
246
248
  TCustomId extends string = string,
247
249
  TPath extends string = string,
250
+ TLoaderContext extends Record<string, any> = AnyContext,
248
251
  TLoader = unknown,
249
- TParentSearchSchema extends AnySearchSchema = {},
250
- TSearchSchema extends AnySearchSchema = {},
251
- TFullSearchSchema extends AnySearchSchema = TSearchSchema,
252
+ TSearchSchema extends Record<string, any> = {},
253
+ TFullSearchSchema extends Record<string, any> = TSearchSchema,
252
254
  TParams extends AnyPathParams = {},
253
255
  TAllParams = ParamsFallback<TPath, TParams>,
254
- TParentContext extends AnyContext = AnyContext,
255
- TAllParentContext extends AnyContext = AnyContext,
256
+ TParentContext extends Record<string, any> = AnyContext,
257
+ TAllParentContext extends Record<string, any> = AnyContext,
256
258
  TRouteContext extends RouteContext = RouteContext,
257
- TAllContext extends AnyContext = AnyContext,
259
+ TAllContext extends Record<string, any> = AnyContext,
258
260
  > = RoutePathOptions<TCustomId, TPath> & {
259
261
  getParentRoute: () => TParentRoute
260
262
  validateSearch?: SearchSchemaValidator<TSearchSchema>
261
- loader?: LoaderFn<
262
- TLoader,
263
- TSearchSchema,
264
- TFullSearchSchema,
265
- TAllParams,
266
- NoInfer<TRouteContext>,
267
- TAllContext
268
- >
263
+ loaderContext?: (opts: { search: TFullSearchSchema }) => TLoaderContext
269
264
  } & (keyof PickRequired<RouteContext> extends never
270
265
  ? // This async function is called before a route is loaded.
271
266
  // If an error is thrown here, the route's loader will not be called.
@@ -275,10 +270,8 @@ export type BaseRouteOptions<
275
270
  beforeLoad?: BeforeLoadFn<
276
271
  TParentRoute,
277
272
  TAllParams,
278
- TSearchSchema,
279
- TFullSearchSchema,
280
- TParentContext,
281
273
  TAllParentContext,
274
+ NoInfer<TLoaderContext>,
282
275
  TRouteContext
283
276
  >
284
277
  }
@@ -286,14 +279,19 @@ export type BaseRouteOptions<
286
279
  beforeLoad: BeforeLoadFn<
287
280
  TParentRoute,
288
281
  TAllParams,
289
- TSearchSchema,
290
- TFullSearchSchema,
291
- TParentContext,
292
282
  TAllParentContext,
283
+ NoInfer<TLoaderContext>,
293
284
  TRouteContext
294
285
  >
295
- }) &
296
- ([TLoader] extends [never]
286
+ }) & {
287
+ loader?: LoaderFn<
288
+ TLoader,
289
+ TAllParams,
290
+ NoInfer<TLoaderContext>,
291
+ NoInfer<TAllContext>,
292
+ NoInfer<TRouteContext>
293
+ >
294
+ } & ([TLoader] extends [never]
297
295
  ? {
298
296
  loader: 'Loaders must return a type other than never. If you are throwing a redirect() and not returning anything, return a redirect() instead.'
299
297
  }
@@ -319,38 +317,24 @@ export type BaseRouteOptions<
319
317
  type BeforeLoadFn<
320
318
  TParentRoute,
321
319
  TAllParams,
322
- TSearchSchema,
323
- TFullSearchSchema,
324
320
  TParentContext,
325
- TAllParentContext,
321
+ TLoaderContext,
326
322
  TRouteContext,
327
- > = (
328
- opts: {
329
- params: TAllParams
330
- routeSearch: TSearchSchema
331
- search: TFullSearchSchema
332
- abortController: AbortController
333
- preload: boolean
334
- } & (TParentRoute extends undefined
335
- ? {
336
- context?: TAllParentContext
337
- parentContext?: TParentContext
338
- }
339
- : {
340
- context: TAllParentContext
341
- parentContext: TParentContext
342
- }),
343
- ) => Promise<TRouteContext> | TRouteContext | void
323
+ > = (opts: {
324
+ abortController: AbortController
325
+ preload: boolean
326
+ params: TAllParams
327
+ context: Expand<TParentContext & TLoaderContext>
328
+ }) => Promise<TRouteContext> | TRouteContext | void
344
329
 
345
330
  export type UpdatableRouteOptions<
346
331
  TLoader,
347
- TSearchSchema extends AnySearchSchema,
348
- TFullSearchSchema extends AnySearchSchema,
332
+ TSearchSchema extends Record<string, any>,
333
+ TFullSearchSchema extends Record<string, any>,
349
334
  TAllParams extends AnyPathParams,
350
- TRouteContext extends AnyContext,
351
- TAllContext extends AnyContext,
335
+ TRouteContext extends Record<string, any>,
336
+ TAllContext extends Record<string, any>,
352
337
  > = MetaOptions & {
353
- key?: null | false | GetKeyFn<TFullSearchSchema, TAllParams>
354
338
  // If true, this route will be matched as case-sensitive
355
339
  caseSensitive?: boolean
356
340
  // If true, this route will be forcefully wrapped in a suspense boundary
@@ -439,48 +423,33 @@ export type ParentParams<TParentParams> = AnyPathParams extends TParentParams
439
423
 
440
424
  export type LoaderFn<
441
425
  TLoader = unknown,
442
- TSearchSchema extends AnySearchSchema = {},
443
- TFullSearchSchema extends AnySearchSchema = {},
444
426
  TAllParams = {},
445
- TContext extends AnyContext = AnyContext,
446
- TAllContext extends AnyContext = AnyContext,
427
+ TLoaderContext extends Record<string, any> = AnyContext,
428
+ TAllContext extends Record<string, any> = AnyContext,
429
+ TRouteContext extends Record<string, any> = AnyContext,
447
430
  > = (
448
431
  match: LoaderContext<
449
- TSearchSchema,
450
- TFullSearchSchema,
451
432
  TAllParams,
452
- TContext,
453
- TAllContext
433
+ TLoaderContext,
434
+ TAllContext,
435
+ TRouteContext
454
436
  > & {
455
437
  parentMatchPromise?: Promise<void>
456
438
  },
457
439
  ) => Promise<TLoader> | TLoader
458
440
 
459
- export type GetKeyFn<
460
- TFullSearchSchema extends AnySearchSchema = {},
461
- TAllParams = {},
462
- > = (loaderContext: { params: TAllParams; search: TFullSearchSchema }) => any
463
-
464
441
  export interface LoaderContext<
465
- TSearchSchema extends AnySearchSchema = {},
466
- TFullSearchSchema extends AnySearchSchema = {},
467
442
  TAllParams = {},
468
- TContext extends AnyContext = AnyContext,
469
- TAllContext extends AnyContext = AnyContext,
443
+ TLoaderContext = {},
444
+ TAllContext extends Record<string, any> = AnyContext,
445
+ TRouteContext extends Record<string, any> = AnyContext,
470
446
  > {
471
- params: TAllParams
472
- routeSearch: TSearchSchema
473
- search: TFullSearchSchema
474
447
  abortController: AbortController
475
448
  preload: boolean
476
- routeContext: TContext
477
- context: TAllContext
449
+ params: TAllParams
450
+ context: DeepMergeAll<[TAllContext, TLoaderContext, TRouteContext]>
478
451
  }
479
452
 
480
- export type UnloaderFn<TPath extends string> = (
481
- routeMatch: RouteMatch<any, Route>,
482
- ) => void
483
-
484
453
  export type SearchFilter<T, U = T> = (prev: T) => U
485
454
 
486
455
  export type ResolveId<
@@ -492,22 +461,16 @@ export type ResolveId<
492
461
  : RootRouteId
493
462
 
494
463
  export type InferFullSearchSchema<TRoute> = TRoute extends {
495
- isRoot: true
496
464
  types: {
497
- searchSchema: infer TSearchSchema
465
+ fullSearchSchema: infer TFullSearchSchema
498
466
  }
499
467
  }
500
- ? TSearchSchema
501
- : TRoute extends {
502
- types: {
503
- fullSearchSchema: infer TFullSearchSchema
504
- }
505
- }
506
468
  ? TFullSearchSchema
507
469
  : {}
508
470
 
509
- export type ResolveFullSearchSchema<TParentRoute, TSearchSchema> =
510
- InferFullSearchSchema<TParentRoute> & TSearchSchema
471
+ export type ResolveFullSearchSchema<TParentRoute, TSearchSchema> = Expand<
472
+ DeepMerge<InferFullSearchSchema<TParentRoute>, TSearchSchema>
473
+ >
511
474
 
512
475
  export interface AnyRoute
513
476
  extends Route<
@@ -527,6 +490,7 @@ export interface AnyRoute
527
490
  any,
528
491
  any,
529
492
  any,
493
+ any,
530
494
  any
531
495
  > {}
532
496
 
@@ -565,6 +529,7 @@ export type RouteConstraints = {
565
529
  TFullPath: string
566
530
  TCustomId: string
567
531
  TId: string
532
+ TLoaderContext: Record<string, any>
568
533
  TSearchSchema: AnySearchSchema
569
534
  TFullSearchSchema: AnySearchSchema
570
535
  TParams: Record<string, any>
@@ -591,6 +556,7 @@ export class Route<
591
556
  TCustomId,
592
557
  TPath
593
558
  >,
559
+ TLoaderContext extends RouteConstraints['TLoaderContext'] = AnyContext,
594
560
  TLoader = unknown,
595
561
  TSearchSchema extends RouteConstraints['TSearchSchema'] = {},
596
562
  TFullSearchSchema extends RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<
@@ -640,8 +606,8 @@ export class Route<
640
606
  TParentRoute,
641
607
  TCustomId,
642
608
  TPath,
609
+ TLoaderContext,
643
610
  TLoader,
644
- InferFullSearchSchema<TParentRoute>,
645
611
  TSearchSchema,
646
612
  TFullSearchSchema,
647
613
  TParams,
@@ -671,8 +637,8 @@ export class Route<
671
637
  TParentRoute,
672
638
  TCustomId,
673
639
  TPath,
640
+ TLoaderContext,
674
641
  TLoader,
675
- InferFullSearchSchema<TParentRoute>,
676
642
  TSearchSchema,
677
643
  TFullSearchSchema,
678
644
  TParams,
@@ -704,9 +670,16 @@ export class Route<
704
670
  TParentRoute,
705
671
  TCustomId,
706
672
  TPath,
707
- InferFullSearchSchema<TParentRoute>,
673
+ TLoaderContext,
674
+ TLoader,
708
675
  TSearchSchema,
709
- TParams
676
+ TFullSearchSchema,
677
+ TParams,
678
+ TAllParams,
679
+ TParentContext,
680
+ TAllParentContext,
681
+ TRouteContext,
682
+ TAllContext
710
683
  > &
711
684
  RoutePathOptionsIntersection<TCustomId, TPath>
712
685
 
@@ -768,6 +741,7 @@ export class Route<
768
741
  TFullPath,
769
742
  TCustomId,
770
743
  TId,
744
+ TLoaderContext,
771
745
  TLoader,
772
746
  TSearchSchema,
773
747
  TFullSearchSchema,
@@ -811,8 +785,9 @@ export class RouterContext<TRouterContext extends {}> {
811
785
  constructor() {}
812
786
 
813
787
  createRootRoute = <
788
+ TLoaderContext extends Record<string, any> = AnyContext,
814
789
  TLoader = unknown,
815
- TSearchSchema extends AnySearchSchema = {},
790
+ TSearchSchema extends Record<string, any> = {},
816
791
  TRouteContext extends RouteContext = RouteContext,
817
792
  >(
818
793
  options?: Omit<
@@ -820,10 +795,10 @@ export class RouterContext<TRouterContext extends {}> {
820
795
  AnyRoute,
821
796
  RootRouteId,
822
797
  '',
798
+ TLoaderContext,
823
799
  TLoader,
824
800
  TSearchSchema,
825
801
  TSearchSchema,
826
- TSearchSchema,
827
802
  {},
828
803
  {},
829
804
  TRouterContext,
@@ -838,14 +813,21 @@ export class RouterContext<TRouterContext extends {}> {
838
813
  | 'parseParams'
839
814
  | 'stringifyParams'
840
815
  >,
841
- ): RootRoute<TLoader, TSearchSchema, TRouteContext, TRouterContext> => {
816
+ ): RootRoute<
817
+ TLoaderContext,
818
+ TLoader,
819
+ TSearchSchema,
820
+ TRouteContext,
821
+ TRouterContext
822
+ > => {
842
823
  return new RootRoute(options) as any
843
824
  }
844
825
  }
845
826
 
846
827
  export class RootRoute<
828
+ TLoaderContext extends Record<string, any> = AnyContext,
847
829
  TLoader = unknown,
848
- TSearchSchema extends AnySearchSchema = {},
830
+ TSearchSchema extends Record<string, any> = {},
849
831
  TRouteContext extends RouteContext = RouteContext,
850
832
  TRouterContext extends {} = {},
851
833
  > extends Route<
@@ -854,6 +836,7 @@ export class RootRoute<
854
836
  '/',
855
837
  string,
856
838
  RootRouteId,
839
+ TLoaderContext,
857
840
  TLoader,
858
841
  TSearchSchema,
859
842
  TSearchSchema,
@@ -873,10 +856,10 @@ export class RootRoute<
873
856
  AnyRoute,
874
857
  RootRouteId,
875
858
  '',
859
+ TLoaderContext,
876
860
  TLoader,
877
861
  TSearchSchema,
878
862
  TSearchSchema,
879
- TSearchSchema,
880
863
  {},
881
864
  {},
882
865
  TRouterContext,