@tanstack/react-router 1.4.9 → 1.4.10

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/react-router",
3
3
  "author": "Tanner Linsley",
4
- "version": "1.4.9",
4
+ "version": "1.4.10",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router",
@@ -44,7 +44,7 @@
44
44
  "@tanstack/store": "^0.1.3",
45
45
  "tiny-invariant": "^1.3.1",
46
46
  "tiny-warning": "^1.0.3",
47
- "@tanstack/history": "1.4.9"
47
+ "@tanstack/history": "1.4.10"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "rollup --config rollup.config.js"
package/src/Matches.tsx CHANGED
@@ -4,7 +4,7 @@ import warning from 'tiny-warning'
4
4
  import { CatchBoundary, ErrorComponent } from './CatchBoundary'
5
5
  import { useRouter, useRouterState } from './RouterProvider'
6
6
  import { ResolveRelativePath, ToOptions } from './link'
7
- import { AnyRoute, ReactNode } from './route'
7
+ import { AnyRoute, ReactNode, RootSearchSchema } from './route'
8
8
  import {
9
9
  ParseRoute,
10
10
  RouteById,
@@ -13,7 +13,7 @@ import {
13
13
  RoutePaths,
14
14
  } from './routeInfo'
15
15
  import { RegisteredRouter, RouterState } from './router'
16
- import { GetTFrom, NoInfer, StrictOrFrom, pick } from './utils'
16
+ import { NoInfer, StrictOrFrom, pick } from './utils'
17
17
 
18
18
  export const matchContext = React.createContext<string | undefined>(undefined)
19
19
 
@@ -36,7 +36,10 @@ export interface RouteMatch<
36
36
  loaderData?: RouteById<TRouteTree, TRouteId>['types']['loaderData']
37
37
  routeContext: RouteById<TRouteTree, TRouteId>['types']['routeContext']
38
38
  context: RouteById<TRouteTree, TRouteId>['types']['allContext']
39
- search: RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema']
39
+ search: Exclude<
40
+ RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'],
41
+ RootSearchSchema
42
+ >
40
43
  fetchCount: number
41
44
  abortController: AbortController
42
45
  cause: 'preload' | 'enter' | 'stay'
@@ -291,14 +294,12 @@ export function getRenderedMatches(state: RouterState) {
291
294
  }
292
295
 
293
296
  export function useMatch<
294
- TOpts extends StrictOrFrom<TFrom>,
295
297
  TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
296
298
  TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,
297
- TFromInferred extends RouteIds<TRouteTree> = GetTFrom<TOpts, TRouteTree>,
298
- TRouteMatchState = RouteMatch<TRouteTree, TFromInferred>,
299
+ TRouteMatchState = RouteMatch<TRouteTree, TFrom>,
299
300
  TSelected = TRouteMatchState,
300
301
  >(
301
- opts: TOpts & {
302
+ opts: StrictOrFrom<TFrom> & {
302
303
  select?: (match: TRouteMatchState) => TSelected
303
304
  },
304
305
  ): TSelected {
@@ -377,17 +378,15 @@ export function useParentMatches<T = RouteMatch[]>(opts?: {
377
378
  }
378
379
 
379
380
  export function useLoaderDeps<
380
- TOpts extends StrictOrFrom<TFrom>,
381
381
  TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
382
382
  TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,
383
- TFromInferred extends RouteIds<TRouteTree> = GetTFrom<TOpts, TRouteTree>,
384
- TRouteMatch extends RouteMatch<TRouteTree, TFromInferred> = RouteMatch<
383
+ TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<
385
384
  TRouteTree,
386
- TFromInferred
385
+ TFrom
387
386
  >,
388
387
  TSelected = Required<TRouteMatch>['loaderDeps'],
389
388
  >(
390
- opts: TOpts & {
389
+ opts: StrictOrFrom<TFrom> & {
391
390
  select?: (match: TRouteMatch) => TSelected
392
391
  },
393
392
  ): TSelected {
@@ -402,17 +401,15 @@ export function useLoaderDeps<
402
401
  }
403
402
 
404
403
  export function useLoaderData<
405
- TOpts extends StrictOrFrom<TFrom>,
406
404
  TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
407
405
  TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,
408
- TFromInferred extends RouteIds<TRouteTree> = GetTFrom<TOpts, TRouteTree>,
409
- TRouteMatch extends RouteMatch<TRouteTree, TFromInferred> = RouteMatch<
406
+ TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<
410
407
  TRouteTree,
411
- TFromInferred
408
+ TFrom
412
409
  >,
413
410
  TSelected = Required<TRouteMatch>['loaderData'],
414
411
  >(
415
- opts: TOpts & {
412
+ opts: StrictOrFrom<TFrom> & {
416
413
  select?: (match: TRouteMatch) => TSelected
417
414
  },
418
415
  ): TSelected {
package/src/useParams.tsx CHANGED
@@ -1,20 +1,18 @@
1
1
  import { AnyRoute } from './route'
2
- import { RouteIds, RouteById, AllParams } from './routeInfo'
2
+ import { RouteIds, RouteById } from './routeInfo'
3
3
  import { RegisteredRouter } from './router'
4
4
  import { last } from './utils'
5
5
  import { useRouterState } from './RouterProvider'
6
- import { StrictOrFrom, GetTFrom } from './utils'
6
+ import { StrictOrFrom } from './utils'
7
7
  import { getRenderedMatches } from './Matches'
8
8
 
9
9
  export function useParams<
10
- TOpts extends StrictOrFrom<TFrom>,
11
10
  TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
12
11
  TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,
13
- TFromInferred = GetTFrom<TOpts, TRouteTree>,
14
- TParams = RouteById<TRouteTree, TFromInferred>['types']['allParams'],
12
+ TParams = RouteById<TRouteTree, TFrom>['types']['allParams'],
15
13
  TSelected = TParams,
16
14
  >(
17
- opts: TOpts & {
15
+ opts: StrictOrFrom<TFrom> & {
18
16
  select?: (params: TParams) => TSelected
19
17
  },
20
18
  ): TSelected {
package/src/useSearch.tsx CHANGED
@@ -1,19 +1,17 @@
1
- import { AnyRoute } from './route'
1
+ import { AnyRoute, RootSearchSchema } from './route'
2
2
  import { RouteIds, RouteById } from './routeInfo'
3
3
  import { RegisteredRouter } from './router'
4
4
  import { RouteMatch } from './Matches'
5
5
  import { useMatch } from './Matches'
6
- import { StrictOrFrom, GetTFrom } from './utils'
6
+ import { StrictOrFrom } from './utils'
7
7
 
8
8
  export function useSearch<
9
- TOpts extends StrictOrFrom<TFrom>,
10
9
  TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
11
10
  TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,
12
- TFromInferred = GetTFrom<TOpts, TRouteTree>,
13
- TSearch = RouteById<TRouteTree, TFromInferred>['types']['fullSearchSchema'],
11
+ TSearch = Exclude<RouteById<TRouteTree, TFrom>['types']['fullSearchSchema'], RootSearchSchema>,
14
12
  TSelected = TSearch,
15
13
  >(
16
- opts: TOpts & {
14
+ opts: StrictOrFrom<TFrom> & {
17
15
  select?: (search: TSearch) => TSelected
18
16
  },
19
17
  ) : TSelected {
package/src/utils.ts CHANGED
@@ -306,12 +306,6 @@ export type StrictOrFrom<TFrom> =
306
306
  strict: false
307
307
  }
308
308
 
309
- export type GetTFrom<T, TRouteTree extends AnyRoute> = T extends StrictOrFrom<
310
- infer TFrom extends RouteIds<TRouteTree>
311
- >
312
- ? TFrom
313
- : never
314
-
315
309
  export function useRouteContext<
316
310
  TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
317
311
  TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,