@tanstack/react-router 1.27.0 → 1.28.1
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.cjs.map +1 -1
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +9 -10
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +32 -24
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +42 -45
- package/dist/cjs/routeInfo.d.cts +5 -7
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +1 -1
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +5 -3
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/fileRoute.d.ts +9 -10
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/link.d.ts +32 -24
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/route.d.ts +42 -45
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/routeInfo.d.ts +5 -7
- package/dist/esm/router.d.ts +1 -1
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/utils.d.ts +5 -3
- package/dist/esm/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/Matches.tsx +2 -2
- package/src/fileRoute.ts +17 -36
- package/src/index.tsx +0 -1
- package/src/link.tsx +187 -82
- package/src/route.ts +153 -186
- package/src/routeInfo.ts +5 -7
- package/src/router.ts +5 -5
- package/src/useParams.tsx +2 -2
- package/src/utils.ts +10 -6
package/src/routeInfo.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Expand, UnionToIntersection, UnionToTuple } from './utils'
|
|
|
4
4
|
export type ParseRoute<TRouteTree, TAcc = TRouteTree> = TRouteTree extends {
|
|
5
5
|
types: { children: infer TChildren }
|
|
6
6
|
}
|
|
7
|
-
? TChildren extends
|
|
7
|
+
? TChildren extends ReadonlyArray<unknown>
|
|
8
8
|
? ParseRoute<TChildren[number], TAcc | TChildren[number]>
|
|
9
9
|
: TAcc
|
|
10
10
|
: TAcc
|
|
@@ -14,7 +14,7 @@ export type RoutesById<TRouteTree extends AnyRoute> = {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export type RouteById<TRouteTree extends AnyRoute, TId> = Extract<
|
|
17
|
-
|
|
17
|
+
RoutesById<TRouteTree>[TId],
|
|
18
18
|
AnyRoute
|
|
19
19
|
>
|
|
20
20
|
|
|
@@ -56,11 +56,9 @@ type Reduce<TValue extends Array<any>, TResult = unknown> = TValue extends [
|
|
|
56
56
|
: TResult
|
|
57
57
|
|
|
58
58
|
export type FullSearchSchema<TRouteTree extends AnyRoute> = Partial<
|
|
59
|
-
|
|
60
|
-
Reduce<UnionToTuple<ParseRoute<TRouteTree>['types']['fullSearchSchema']>>
|
|
61
|
-
>
|
|
59
|
+
Reduce<UnionToTuple<ParseRoute<TRouteTree>['types']['fullSearchSchema']>>
|
|
62
60
|
>
|
|
63
61
|
|
|
64
|
-
export type AllParams<TRouteTree extends AnyRoute> =
|
|
65
|
-
|
|
62
|
+
export type AllParams<TRouteTree extends AnyRoute> = UnionToIntersection<
|
|
63
|
+
ParseRoute<TRouteTree>['types']['allParams']
|
|
66
64
|
>
|
package/src/router.ts
CHANGED
|
@@ -261,9 +261,9 @@ export function createRouter<
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
export class Router<
|
|
264
|
-
TRouteTree extends AnyRoute = AnyRoute,
|
|
265
|
-
TDehydrated extends Record<string, any> = Record<string, any>,
|
|
266
|
-
TSerializedError extends Record<string, any> = Record<string, any>,
|
|
264
|
+
in out TRouteTree extends AnyRoute = AnyRoute,
|
|
265
|
+
in out TDehydrated extends Record<string, any> = Record<string, any>,
|
|
266
|
+
in out TSerializedError extends Record<string, any> = Record<string, any>,
|
|
267
267
|
> {
|
|
268
268
|
// Option-independent properties
|
|
269
269
|
tempLocationKey: string | undefined = `${Math.round(
|
|
@@ -1268,8 +1268,8 @@ export class Router<
|
|
|
1268
1268
|
preload: !!preload,
|
|
1269
1269
|
context: parentContext,
|
|
1270
1270
|
location,
|
|
1271
|
-
navigate: (opts) =>
|
|
1272
|
-
this.navigate({ ...opts, from: match.pathname }
|
|
1271
|
+
navigate: (opts: any) =>
|
|
1272
|
+
this.navigate({ ...opts, from: match.pathname }),
|
|
1273
1273
|
buildLocation: this.buildLocation,
|
|
1274
1274
|
cause: preload ? 'preload' : match.cause,
|
|
1275
1275
|
})) ?? ({} as any)
|
package/src/useParams.tsx
CHANGED
|
@@ -21,7 +21,7 @@ export function useParams<
|
|
|
21
21
|
return useMatch({
|
|
22
22
|
...opts,
|
|
23
23
|
select: (match) => {
|
|
24
|
-
return opts.select ? opts.select(match.params) : match.params
|
|
24
|
+
return opts.select ? opts.select(match.params as TParams) : match.params
|
|
25
25
|
},
|
|
26
|
-
})
|
|
26
|
+
}) as TSelected
|
|
27
27
|
}
|
package/src/utils.ts
CHANGED
|
@@ -15,12 +15,14 @@ export type PickRequired<T> = {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
// from https://stackoverflow.com/a/76458160
|
|
18
|
-
export type WithoutEmpty<T> = T extends
|
|
18
|
+
export type WithoutEmpty<T> = T extends any ? ({} extends T ? never : T) : never
|
|
19
19
|
|
|
20
20
|
// export type Expand<T> = T
|
|
21
21
|
export type Expand<T> = T extends object
|
|
22
22
|
? T extends infer O
|
|
23
|
-
?
|
|
23
|
+
? O extends Function
|
|
24
|
+
? O
|
|
25
|
+
: { [K in keyof O]: O[K] }
|
|
24
26
|
: never
|
|
25
27
|
: T
|
|
26
28
|
|
|
@@ -36,10 +38,12 @@ export type DeepPartial<T> = T extends object
|
|
|
36
38
|
}
|
|
37
39
|
: T
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
export type MakeDifferenceOptional<TLeft, TRight> = Omit<
|
|
42
|
+
TRight,
|
|
43
|
+
keyof TLeft
|
|
44
|
+
> & {
|
|
45
|
+
[K in keyof TLeft & keyof TRight]?: TRight[K]
|
|
46
|
+
}
|
|
43
47
|
|
|
44
48
|
// from https://stackoverflow.com/a/53955431
|
|
45
49
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|