@tanstack/react-router 1.28.8 → 1.29.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/Matches.tsx CHANGED
@@ -1,25 +1,15 @@
1
1
  import * as React from 'react'
2
2
  import invariant from 'tiny-invariant'
3
3
  import warning from 'tiny-warning'
4
- import { set } from 'zod'
5
4
  import { CatchBoundary, ErrorComponent } from './CatchBoundary'
6
5
  import { useRouterState } from './useRouterState'
7
6
  import { useRouter } from './useRouter'
8
7
  import { createControlledPromise, pick } from './utils'
9
8
  import { CatchNotFound, DefaultGlobalNotFound, isNotFound } from './not-found'
10
9
  import { isRedirect } from './redirects'
11
- import {
12
- type AnyRouter,
13
- type RegisteredRouter,
14
- type RouterState,
15
- } from './router'
10
+ import { type AnyRouter, type RegisteredRouter } from './router'
16
11
  import type { ResolveRelativePath, ToOptions } from './link'
17
- import type {
18
- AnyRoute,
19
- ReactNode,
20
- RootSearchSchema,
21
- StaticDataRouteOption,
22
- } from './route'
12
+ import type { AnyRoute, ReactNode, StaticDataRouteOption } from './route'
23
13
  import type {
24
14
  AllParams,
25
15
  FullSearchSchema,
@@ -40,16 +30,18 @@ import type {
40
30
  export const matchContext = React.createContext<string | undefined>(undefined)
41
31
 
42
32
  export interface RouteMatch<
43
- TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
44
- TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],
45
- TReturnIntersection extends boolean = false,
33
+ TRouteId,
34
+ TAllParams,
35
+ TFullSearchSchema,
36
+ TLoaderData,
37
+ TAllContext,
38
+ TRouteContext,
39
+ TLoaderDeps,
46
40
  > {
47
41
  id: string
48
42
  routeId: TRouteId
49
43
  pathname: string
50
- params: TReturnIntersection extends false
51
- ? RouteById<TRouteTree, TRouteId>['types']['allParams']
52
- : Expand<Partial<AllParams<TRouteTree>>>
44
+ params: TAllParams
53
45
  status: 'pending' | 'success' | 'error' | 'redirected' | 'notFound'
54
46
  isFetching: boolean
55
47
  error: unknown
@@ -57,22 +49,15 @@ export interface RouteMatch<
57
49
  searchError: unknown
58
50
  updatedAt: number
59
51
  loadPromise: ControlledPromise<void>
60
- loaderPromise: Promise<RouteById<TRouteTree, TRouteId>['types']['loaderData']>
61
- loaderData?: RouteById<TRouteTree, TRouteId>['types']['loaderData']
62
- routeContext: RouteById<TRouteTree, TRouteId>['types']['routeContext']
63
- context: RouteById<TRouteTree, TRouteId>['types']['allContext']
64
- search: TReturnIntersection extends false
65
- ? Exclude<
66
- RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'],
67
- RootSearchSchema
68
- >
69
- : Expand<
70
- Partial<Omit<FullSearchSchema<TRouteTree>, keyof RootSearchSchema>>
71
- >
52
+ loaderPromise: Promise<TLoaderData>
53
+ loaderData?: TLoaderData
54
+ routeContext: TRouteContext
55
+ context: TAllContext
56
+ search: TFullSearchSchema
72
57
  fetchCount: number
73
58
  abortController: AbortController
74
59
  cause: 'preload' | 'enter' | 'stay'
75
- loaderDeps: RouteById<TRouteTree, TRouteId>['types']['loaderDeps']
60
+ loaderDeps: TLoaderDeps
76
61
  preload: boolean
77
62
  invalid: boolean
78
63
  meta?: Array<JSX.IntrinsicElements['meta']>
@@ -84,7 +69,32 @@ export interface RouteMatch<
84
69
  minPendingPromise?: ControlledPromise<void>
85
70
  }
86
71
 
87
- export type AnyRouteMatch = RouteMatch<any, any>
72
+ export type MakeRouteMatch<
73
+ TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
74
+ TRouteId = ParseRoute<TRouteTree>['id'],
75
+ TReturnIntersection extends boolean = false,
76
+ TTypes extends AnyRoute['types'] = RouteById<TRouteTree, TRouteId>['types'],
77
+ TAllParams = TReturnIntersection extends false
78
+ ? TTypes['allParams']
79
+ : Partial<AllParams<TRouteTree>>,
80
+ TFullSearchSchema = TReturnIntersection extends false
81
+ ? TTypes['fullSearchSchema']
82
+ : Partial<FullSearchSchema<TRouteTree>>,
83
+ TLoaderData = TTypes['loaderData'],
84
+ TAllContext = TTypes['allContext'],
85
+ TRouteContext = TTypes['routeContext'],
86
+ TLoaderDeps = TTypes['loaderDeps'],
87
+ > = RouteMatch<
88
+ TRouteId,
89
+ TAllParams,
90
+ TFullSearchSchema,
91
+ TLoaderData,
92
+ TAllContext,
93
+ TRouteContext,
94
+ TLoaderDeps
95
+ >
96
+
97
+ export type AnyRouteMatch = RouteMatch<any, any, any, any, any, any, any>
88
98
 
89
99
  export function Matches() {
90
100
  const matchId = useRouterState({
@@ -503,11 +513,11 @@ export function useMatch<
503
513
  TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
504
514
  TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,
505
515
  TReturnIntersection extends boolean = false,
506
- TRouteMatchState = RouteMatch<TRouteTree, TFrom, TReturnIntersection>,
507
- TSelected = TRouteMatchState,
516
+ TRouteMatch = MakeRouteMatch<TRouteTree, TFrom, TReturnIntersection>,
517
+ TSelected = TRouteMatch,
508
518
  >(
509
519
  opts: StrictOrFrom<TFrom, TReturnIntersection> & {
510
- select?: (match: TRouteMatchState) => TSelected
520
+ select?: (match: TRouteMatch) => TSelected
511
521
  },
512
522
  ): TSelected {
513
523
  const nearestMatchId = React.useContext(matchContext)
@@ -536,7 +546,7 @@ export function useMatches<
536
546
  TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
537
547
  TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],
538
548
  TReturnIntersection extends boolean = false,
539
- TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,
549
+ TRouteMatch = MakeRouteMatch<TRouteTree, TRouteId, TReturnIntersection>,
540
550
  T = Array<TRouteMatch>,
541
551
  >(opts?: {
542
552
  select?: (matches: Array<TRouteMatch>) => T
@@ -556,7 +566,7 @@ export function useParentMatches<
556
566
  TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
557
567
  TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],
558
568
  TReturnIntersection extends boolean = false,
559
- TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,
569
+ TRouteMatch = MakeRouteMatch<TRouteTree, TRouteId, TReturnIntersection>,
560
570
  T = Array<TRouteMatch>,
561
571
  >(opts?: {
562
572
  select?: (matches: Array<TRouteMatch>) => T
@@ -581,7 +591,7 @@ export function useChildMatches<
581
591
  TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
582
592
  TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],
583
593
  TReturnIntersection extends boolean = false,
584
- TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,
594
+ TRouteMatch = MakeRouteMatch<TRouteTree, TRouteId, TReturnIntersection>,
585
595
  T = Array<TRouteMatch>,
586
596
  >(opts?: {
587
597
  select?: (matches: Array<TRouteMatch>) => T
@@ -604,7 +614,7 @@ export function useChildMatches<
604
614
  export function useLoaderDeps<
605
615
  TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
606
616
  TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,
607
- TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<
617
+ TRouteMatch extends MakeRouteMatch<TRouteTree, TFrom> = MakeRouteMatch<
608
618
  TRouteTree,
609
619
  TFrom
610
620
  >,
@@ -627,7 +637,7 @@ export function useLoaderDeps<
627
637
  export function useLoaderData<
628
638
  TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
629
639
  TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,
630
- TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<
640
+ TRouteMatch extends MakeRouteMatch<TRouteTree, TFrom> = MakeRouteMatch<
631
641
  TRouteTree,
632
642
  TFrom
633
643
  >,
@@ -16,7 +16,7 @@ import type {
16
16
  RouterState,
17
17
  } from './router'
18
18
 
19
- import type { RouteMatch } from './Matches'
19
+ import type { MakeRouteMatch } from './Matches'
20
20
 
21
21
  export interface CommitLocationOptions {
22
22
  replace?: boolean
@@ -229,7 +229,7 @@ function Transitioner() {
229
229
  export function getRouteMatch<TRouteTree extends AnyRoute>(
230
230
  state: RouterState<TRouteTree>,
231
231
  id: string,
232
- ): undefined | RouteMatch<TRouteTree> {
232
+ ): undefined | MakeRouteMatch<TRouteTree> {
233
233
  return [
234
234
  ...state.cachedMatches,
235
235
  ...(state.pendingMatches ?? []),
package/src/fileRoute.ts CHANGED
@@ -25,7 +25,7 @@ import type {
25
25
  UpdatableRouteOptions,
26
26
  } from './route'
27
27
  import type { Assign, IsAny } from './utils'
28
- import type { RouteMatch } from './Matches'
28
+ import type { MakeRouteMatch } from './Matches'
29
29
  import type { NoInfer } from '@tanstack/react-store'
30
30
  import type { RegisteredRouter } from './router'
31
31
  import type { RouteById, RouteIds } from './routeInfo'
@@ -189,7 +189,15 @@ export class FileRoute<
189
189
  TLoaderDeps,
190
190
  TLoaderDataReturn
191
191
  > &
192
- UpdatableRouteOptions<TAllParams, TFullSearchSchema, TLoaderData>,
192
+ UpdatableRouteOptions<
193
+ TId,
194
+ TAllParams,
195
+ TFullSearchSchema,
196
+ TLoaderData,
197
+ TAllContext,
198
+ TRouteContext,
199
+ TLoaderDeps
200
+ >,
193
201
  ): Route<
194
202
  TParentRoute,
195
203
  TPath,
@@ -255,7 +263,15 @@ export function FileRouteLoader<
255
263
  }
256
264
 
257
265
  export type LazyRouteOptions = Pick<
258
- UpdatableRouteOptions<AnyPathParams, AnySearchSchema, any>,
266
+ UpdatableRouteOptions<
267
+ string,
268
+ AnyPathParams,
269
+ AnySearchSchema,
270
+ {},
271
+ AnyContext,
272
+ AnyContext,
273
+ {}
274
+ >,
259
275
  'component' | 'errorComponent' | 'pendingComponent' | 'notFoundComponent'
260
276
  >
261
277
 
@@ -274,13 +290,13 @@ export class LazyRoute<TRoute extends AnyRoute> {
274
290
  }
275
291
 
276
292
  useMatch = <
277
- TRouteMatchState = RouteMatch<
293
+ TRouteMatch = MakeRouteMatch<
278
294
  RegisteredRouter['routeTree'],
279
295
  TRoute['types']['id']
280
296
  >,
281
- TSelected = TRouteMatchState,
297
+ TSelected = TRouteMatch,
282
298
  >(opts?: {
283
- select?: (match: TRouteMatchState) => TSelected
299
+ select?: (match: TRouteMatch) => TSelected
284
300
  }): TSelected => {
285
301
  return useMatch({ select: opts?.select, from: this.options.id })
286
302
  }
package/src/route.ts CHANGED
@@ -7,8 +7,7 @@ import { notFound } from './not-found'
7
7
  import { useNavigate } from './useNavigate'
8
8
  import type { UseNavigateResult } from './useNavigate'
9
9
  import type * as React from 'react'
10
- import type { RouteMatch } from './Matches'
11
- import type { AnyRouteMatch } from './Matches'
10
+ import type { MakeRouteMatch, RouteMatch } from './Matches'
12
11
  import type { NavigateOptions, ParsePathParams, ToSubOptions } from './link'
13
12
  import type { ParsedLocation } from './location'
14
13
  import type { RouteById, RouteIds, RoutePaths } from './routeInfo'
@@ -93,9 +92,13 @@ export type RouteOptions<
93
92
  TLoaderDataReturn
94
93
  > &
95
94
  UpdatableRouteOptions<
95
+ NoInfer<TCustomId>,
96
96
  NoInfer<TAllParams>,
97
97
  NoInfer<TFullSearchSchema>,
98
- NoInfer<TLoaderData>
98
+ NoInfer<TLoaderData>,
99
+ NoInfer<TAllContext>,
100
+ NoInfer<TRouteContext>,
101
+ NoInfer<TLoaderDeps>
99
102
  >
100
103
 
101
104
  export type ParamsFallback<
@@ -221,44 +224,60 @@ type BeforeLoadFn<
221
224
  cause: 'preload' | 'enter' | 'stay'
222
225
  }) => Promise<TRouteContextReturn> | TRouteContextReturn | void
223
226
 
224
- export type UpdatableRouteOptions<TAllParams, TFullSearchSchema, TLoaderData> =
225
- {
226
- // test?: (args: TAllContext) => void
227
- // If true, this route will be matched as case-sensitive
228
- caseSensitive?: boolean
229
- // If true, this route will be forcefully wrapped in a suspense boundary
230
- wrapInSuspense?: boolean
231
- // The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`
232
- component?: RouteComponent
233
- errorComponent?: false | null | ErrorRouteComponent
234
- notFoundComponent?: NotFoundRouteComponent
235
- pendingComponent?: RouteComponent
236
- pendingMs?: number
237
- pendingMinMs?: number
238
- staleTime?: number
239
- gcTime?: number
240
- preloadStaleTime?: number
241
- preloadGcTime?: number
242
- // Filter functions that can manipulate search params *before* they are passed to links and navigate
243
- // calls that match this route.
244
- preSearchFilters?: Array<SearchFilter<TFullSearchSchema>>
245
- // Filter functions that can manipulate search params *after* they are passed to links and navigate
246
- // calls that match this route.
247
- postSearchFilters?: Array<SearchFilter<TFullSearchSchema>>
248
- onError?: (err: any) => void
249
- // These functions are called as route matches are loaded, stick around and leave the active
250
- // matches
251
- onEnter?: (match: AnyRouteMatch) => void
252
- onStay?: (match: AnyRouteMatch) => void
253
- onLeave?: (match: AnyRouteMatch) => void
254
- meta?: (ctx: {
255
- params: TAllParams
256
- loaderData: TLoaderData
257
- }) => Array<JSX.IntrinsicElements['meta']>
258
- links?: () => Array<JSX.IntrinsicElements['link']>
259
- scripts?: () => Array<JSX.IntrinsicElements['script']>
260
- headers?: (ctx: { loaderData: TLoaderData }) => Record<string, string>
261
- } & UpdatableStaticRouteOption
227
+ export type UpdatableRouteOptions<
228
+ TRouteId,
229
+ TAllParams,
230
+ TFullSearchSchema,
231
+ TLoaderData,
232
+ TAllContext,
233
+ TRouteContext,
234
+ TLoaderDeps,
235
+ TRouteMatch = RouteMatch<
236
+ TRouteId,
237
+ TAllParams,
238
+ TFullSearchSchema,
239
+ TLoaderData,
240
+ TAllContext,
241
+ TRouteContext,
242
+ TLoaderDeps
243
+ >,
244
+ > = {
245
+ // test?: (args: TAllContext) => void
246
+ // If true, this route will be matched as case-sensitive
247
+ caseSensitive?: boolean
248
+ // If true, this route will be forcefully wrapped in a suspense boundary
249
+ wrapInSuspense?: boolean
250
+ // The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`
251
+ component?: RouteComponent
252
+ errorComponent?: false | null | ErrorRouteComponent
253
+ notFoundComponent?: NotFoundRouteComponent
254
+ pendingComponent?: RouteComponent
255
+ pendingMs?: number
256
+ pendingMinMs?: number
257
+ staleTime?: number
258
+ gcTime?: number
259
+ preloadStaleTime?: number
260
+ preloadGcTime?: number
261
+ // Filter functions that can manipulate search params *before* they are passed to links and navigate
262
+ // calls that match this route.
263
+ preSearchFilters?: Array<SearchFilter<TFullSearchSchema>>
264
+ // Filter functions that can manipulate search params *after* they are passed to links and navigate
265
+ // calls that match this route.
266
+ postSearchFilters?: Array<SearchFilter<TFullSearchSchema>>
267
+ onError?: (err: any) => void
268
+ // These functions are called as route matches are loaded, stick around and leave the active
269
+ // matches
270
+ onEnter?: (match: TRouteMatch) => void
271
+ onStay?: (match: TRouteMatch) => void
272
+ onLeave?: (match: TRouteMatch) => void
273
+ meta?: (ctx: {
274
+ params: TAllParams
275
+ loaderData: TLoaderData
276
+ }) => Array<JSX.IntrinsicElements['meta']>
277
+ links?: () => Array<JSX.IntrinsicElements['link']>
278
+ scripts?: () => Array<JSX.IntrinsicElements['script']>
279
+ headers?: (ctx: { loaderData: TLoaderData }) => Record<string, string>
280
+ } & UpdatableStaticRouteOption
262
281
 
263
282
  export type UpdatableStaticRouteOption =
264
283
  {} extends PickRequired<StaticDataRouteOption>
@@ -483,10 +502,10 @@ export class RouteApi<
483
502
 
484
503
  useMatch = <
485
504
  TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
486
- TRouteMatchState = RouteMatch<TRouteTree, TId>,
487
- TSelected = TRouteMatchState,
505
+ TRouteMatch = MakeRouteMatch<TRouteTree, TId>,
506
+ TSelected = TRouteMatch,
488
507
  >(opts?: {
489
- select?: (match: TRouteMatchState) => TSelected
508
+ select?: (match: TRouteMatch) => TSelected
490
509
  }): TSelected => {
491
510
  return useMatch({ select: opts?.select, from: this.id })
492
511
  }
@@ -806,7 +825,15 @@ export class Route<
806
825
  }
807
826
 
808
827
  update = (
809
- options: UpdatableRouteOptions<TAllParams, TFullSearchSchema, TLoaderData>,
828
+ options: UpdatableRouteOptions<
829
+ TCustomId,
830
+ TAllParams,
831
+ TFullSearchSchema,
832
+ TLoaderData,
833
+ TAllContext,
834
+ TRouteContext,
835
+ TLoaderDeps
836
+ >,
810
837
  ): this => {
811
838
  Object.assign(this.options, options)
812
839
  return this
@@ -819,10 +846,10 @@ export class Route<
819
846
 
820
847
  useMatch = <
821
848
  TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
822
- TRouteMatchState = RouteMatch<TRouteTree, TId>,
823
- TSelected = TRouteMatchState,
849
+ TRouteMatch = MakeRouteMatch<TRouteTree, TId>,
850
+ TSelected = TRouteMatch,
824
851
  >(opts?: {
825
- select?: (match: TRouteMatchState) => TSelected
852
+ select?: (match: TRouteMatch) => TSelected
826
853
  }): TSelected => {
827
854
  return useMatch({ ...opts, from: this.id })
828
855
  }
package/src/router.ts CHANGED
@@ -60,7 +60,12 @@ import type {
60
60
  Updater,
61
61
  } from './utils'
62
62
  import type { RouteComponent } from './route'
63
- import type { AnyRouteMatch, MatchRouteOptions, RouteMatch } from './Matches'
63
+ import type {
64
+ AnyRouteMatch,
65
+ MakeRouteMatch,
66
+ MatchRouteOptions,
67
+ RouteMatch,
68
+ } from './Matches'
64
69
  import type { ParsedLocation } from './location'
65
70
  import type { SearchParser, SearchSerializer } from './searchParams'
66
71
  import type {
@@ -164,13 +169,16 @@ export interface RouterErrorSerializer<TSerializedError> {
164
169
  deserialize: (err: TSerializedError) => unknown
165
170
  }
166
171
 
167
- export interface RouterState<TRouteTree extends AnyRoute = AnyRoute> {
172
+ export interface RouterState<
173
+ TRouteTree extends AnyRoute = AnyRoute,
174
+ TRouteMatch = MakeRouteMatch<TRouteTree>,
175
+ > {
168
176
  status: 'pending' | 'idle'
169
177
  isLoading: boolean
170
178
  isTransitioning: boolean
171
- matches: Array<RouteMatch<TRouteTree>>
172
- pendingMatches?: Array<RouteMatch<TRouteTree>>
173
- cachedMatches: Array<RouteMatch<TRouteTree>>
179
+ matches: Array<TRouteMatch>
180
+ pendingMatches?: Array<TRouteMatch>
181
+ cachedMatches: Array<TRouteMatch>
174
182
  location: ParsedLocation<FullSearchSchema<TRouteTree>>
175
183
  resolvedLocation: ParsedLocation<FullSearchSchema<TRouteTree>>
176
184
  statusCode: number
@@ -202,7 +210,7 @@ export interface DehydratedRouterState {
202
210
  }
203
211
 
204
212
  export type DehydratedRouteMatch = Pick<
205
- RouteMatch,
213
+ MakeRouteMatch,
206
214
  'id' | 'status' | 'updatedAt' | 'loaderData'
207
215
  >
208
216
 
@@ -607,12 +615,11 @@ export class Router<
607
615
  return this.routesById as Record<string, AnyRoute>
608
616
  }
609
617
 
610
- // eslint-disable-next-line no-shadow
611
- matchRoutes = <TRouteTree extends AnyRoute>(
618
+ matchRoutes = (
612
619
  pathname: string,
613
620
  locationSearch: AnySearchSchema,
614
621
  opts?: { preload?: boolean; throwOnError?: boolean },
615
- ): Array<RouteMatch<TRouteTree>> => {
622
+ ): Array<AnyRouteMatch> => {
616
623
  let routeParams: Record<string, string> = {}
617
624
 
618
625
  const foundRoute = this.flatRoutes.find((route) => {
@@ -719,7 +726,6 @@ export class Router<
719
726
  // which is used to uniquely identify the route match in state
720
727
 
721
728
  const parentMatch = matches[index - 1]
722
- const isLast = index === matchedRoutes.length - 1
723
729
 
724
730
  const [preMatchSearch, searchError]: [Record<string, any>, any] = (() => {
725
731
  // Validate the search params and stabilize them
@@ -881,7 +887,7 @@ export class Router<
881
887
  dest: BuildNextOptions & {
882
888
  unmaskOnReload?: boolean
883
889
  } = {},
884
- matches?: Array<AnyRouteMatch>,
890
+ matches?: Array<MakeRouteMatch<TRouteTree>>,
885
891
  ): ParsedLocation => {
886
892
  const fromPath = dest.from || this.latestLocation.pathname
887
893
  let fromSearch = dest._fromLocation?.search || this.latestLocation.search
@@ -1172,7 +1178,7 @@ export class Router<
1172
1178
  location: ParsedLocation
1173
1179
  matches: Array<AnyRouteMatch>
1174
1180
  preload?: boolean
1175
- }): Promise<Array<RouteMatch>> => {
1181
+ }): Promise<Array<MakeRouteMatch>> => {
1176
1182
  let latestPromise
1177
1183
  let firstBadMatchIndex: number | undefined
1178
1184
 
@@ -1607,7 +1613,7 @@ export class Router<
1607
1613
  }
1608
1614
 
1609
1615
  invalidate = () => {
1610
- const invalidate = (d: RouteMatch<TRouteTree>) => ({
1616
+ const invalidate = (d: MakeRouteMatch<TRouteTree>) => ({
1611
1617
  ...d,
1612
1618
  invalid: true,
1613
1619
  ...(d.status === 'error' ? ({ status: 'pending' } as const) : {}),
@@ -1652,7 +1658,7 @@ export class Router<
1652
1658
  pathChanged: pathDidChange,
1653
1659
  })
1654
1660
 
1655
- let pendingMatches!: Array<RouteMatch<any, any>>
1661
+ let pendingMatches!: Array<AnyRouteMatch>
1656
1662
  const previousMatches = this.state.matches
1657
1663
 
1658
1664
  this.__store.batch(() => {
@@ -1,5 +1,5 @@
1
1
  import { useMatch } from './Matches'
2
- import type { RouteMatch } from './Matches'
2
+ import type { MakeRouteMatch } from './Matches'
3
3
  import type { AnyRoute } from './route'
4
4
  import type { RouteById, RouteIds } from './routeInfo'
5
5
  import type { RegisteredRouter } from './router'
@@ -17,7 +17,7 @@ export function useRouteContext<
17
17
  ): TSelected {
18
18
  return useMatch({
19
19
  ...(opts as any),
20
- select: (match: RouteMatch) =>
21
- opts.select ? opts.select(match.context as TRouteContext) : match.context,
20
+ select: (match: MakeRouteMatch<TRouteTree, TFrom>) =>
21
+ opts.select ? opts.select(match.context) : match.context,
22
22
  })
23
23
  }
package/src/useSearch.tsx CHANGED
@@ -1,9 +1,8 @@
1
1
  import { useMatch } from './Matches'
2
- import { Expand } from './utils'
3
2
  import type { AnyRoute, RootSearchSchema } from './route'
4
3
  import type { FullSearchSchema, RouteById, RouteIds } from './routeInfo'
5
4
  import type { RegisteredRouter } from './router'
6
- import type { RouteMatch } from './Matches'
5
+ import type { MakeRouteMatch } from './Matches'
7
6
  import type { StrictOrFrom } from './utils'
8
7
 
9
8
  export function useSearch<
@@ -24,8 +23,8 @@ export function useSearch<
24
23
  ): TSelected {
25
24
  return useMatch({
26
25
  ...opts,
27
- select: (match: RouteMatch) => {
28
- return opts.select ? opts.select(match.search as TSearch) : match.search
26
+ select: (match: MakeRouteMatch<TRouteTree, TFrom>) => {
27
+ return opts.select ? opts.select(match.search) : match.search
29
28
  },
30
29
  })
31
30
  }