@tanstack/router-core 0.0.1-beta.8 → 1.20.3-alpha.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.
Files changed (194) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/dist/cjs/Matches.cjs +13 -0
  4. package/dist/cjs/Matches.cjs.map +1 -0
  5. package/dist/cjs/Matches.d.cts +109 -0
  6. package/dist/cjs/RouterProvider.d.cts +26 -0
  7. package/dist/cjs/defer.cjs +25 -0
  8. package/dist/cjs/defer.cjs.map +1 -0
  9. package/dist/cjs/defer.d.cts +20 -0
  10. package/dist/cjs/fileRoute.d.cts +23 -0
  11. package/dist/cjs/history.d.cts +8 -0
  12. package/dist/cjs/index.cjs +80 -0
  13. package/dist/cjs/index.cjs.map +1 -0
  14. package/dist/cjs/index.d.cts +41 -0
  15. package/dist/cjs/link.cjs +5 -0
  16. package/dist/cjs/link.cjs.map +1 -0
  17. package/dist/cjs/link.d.cts +200 -0
  18. package/dist/cjs/location.d.cts +12 -0
  19. package/dist/cjs/manifest.d.cts +24 -0
  20. package/dist/cjs/not-found.cjs +13 -0
  21. package/dist/cjs/not-found.cjs.map +1 -0
  22. package/dist/cjs/not-found.d.cts +20 -0
  23. package/dist/cjs/path.cjs +412 -0
  24. package/dist/cjs/path.cjs.map +1 -0
  25. package/dist/cjs/path.d.cts +56 -0
  26. package/dist/cjs/qss.cjs +38 -0
  27. package/dist/cjs/qss.cjs.map +1 -0
  28. package/dist/cjs/qss.d.cts +22 -0
  29. package/dist/cjs/redirect.cjs +34 -0
  30. package/dist/cjs/redirect.cjs.map +1 -0
  31. package/dist/cjs/redirect.d.cts +38 -0
  32. package/dist/cjs/root.cjs +5 -0
  33. package/dist/cjs/root.cjs.map +1 -0
  34. package/dist/cjs/root.d.cts +2 -0
  35. package/dist/cjs/route.cjs +119 -0
  36. package/dist/cjs/route.cjs.map +1 -0
  37. package/dist/cjs/route.d.cts +422 -0
  38. package/dist/cjs/routeInfo.d.cts +54 -0
  39. package/dist/cjs/router.cjs +1800 -0
  40. package/dist/cjs/router.cjs.map +1 -0
  41. package/dist/cjs/router.d.cts +630 -0
  42. package/dist/cjs/scroll-restoration.cjs +196 -0
  43. package/dist/cjs/scroll-restoration.cjs.map +1 -0
  44. package/dist/cjs/scroll-restoration.d.cts +38 -0
  45. package/dist/cjs/searchMiddleware.cjs +42 -0
  46. package/dist/cjs/searchMiddleware.cjs.map +1 -0
  47. package/dist/cjs/searchMiddleware.d.cts +5 -0
  48. package/dist/cjs/searchParams.cjs +61 -0
  49. package/dist/cjs/searchParams.cjs.map +1 -0
  50. package/dist/cjs/searchParams.d.cts +7 -0
  51. package/dist/cjs/serializer.d.cts +22 -0
  52. package/dist/cjs/structuralSharing.d.cts +4 -0
  53. package/dist/cjs/typePrimitives.d.cts +65 -0
  54. package/dist/cjs/useLoaderData.d.cts +5 -0
  55. package/dist/cjs/useLoaderDeps.d.cts +5 -0
  56. package/dist/cjs/useNavigate.d.cts +3 -0
  57. package/dist/cjs/useParams.d.cts +5 -0
  58. package/dist/cjs/useRouteContext.d.cts +9 -0
  59. package/dist/cjs/useSearch.d.cts +5 -0
  60. package/dist/cjs/utils.cjs +160 -0
  61. package/dist/cjs/utils.cjs.map +1 -0
  62. package/dist/cjs/utils.d.cts +105 -0
  63. package/dist/cjs/validators.d.cts +51 -0
  64. package/dist/esm/Matches.d.ts +109 -0
  65. package/dist/esm/Matches.js +13 -0
  66. package/dist/esm/Matches.js.map +1 -0
  67. package/dist/esm/RouterProvider.d.ts +26 -0
  68. package/dist/esm/defer.d.ts +20 -0
  69. package/dist/esm/defer.js +25 -0
  70. package/dist/esm/defer.js.map +1 -0
  71. package/dist/esm/fileRoute.d.ts +23 -0
  72. package/dist/esm/history.d.ts +8 -0
  73. package/dist/esm/index.d.ts +41 -0
  74. package/dist/esm/index.js +80 -0
  75. package/dist/esm/index.js.map +1 -0
  76. package/dist/esm/link.d.ts +200 -0
  77. package/dist/esm/link.js +5 -0
  78. package/dist/esm/link.js.map +1 -0
  79. package/dist/esm/location.d.ts +12 -0
  80. package/dist/esm/manifest.d.ts +24 -0
  81. package/dist/esm/not-found.d.ts +20 -0
  82. package/dist/esm/not-found.js +13 -0
  83. package/dist/esm/not-found.js.map +1 -0
  84. package/dist/esm/path.d.ts +56 -0
  85. package/dist/esm/path.js +412 -0
  86. package/dist/esm/path.js.map +1 -0
  87. package/dist/esm/qss.d.ts +22 -0
  88. package/dist/esm/qss.js +38 -0
  89. package/dist/esm/qss.js.map +1 -0
  90. package/dist/esm/redirect.d.ts +38 -0
  91. package/dist/esm/redirect.js +34 -0
  92. package/dist/esm/redirect.js.map +1 -0
  93. package/dist/esm/root.d.ts +2 -0
  94. package/dist/esm/root.js +5 -0
  95. package/dist/esm/root.js.map +1 -0
  96. package/dist/esm/route.d.ts +422 -0
  97. package/dist/esm/route.js +119 -0
  98. package/dist/esm/route.js.map +1 -0
  99. package/dist/esm/routeInfo.d.ts +54 -0
  100. package/dist/esm/router.d.ts +630 -0
  101. package/dist/esm/router.js +1800 -0
  102. package/dist/esm/router.js.map +1 -0
  103. package/dist/esm/scroll-restoration.d.ts +38 -0
  104. package/dist/esm/scroll-restoration.js +196 -0
  105. package/dist/esm/scroll-restoration.js.map +1 -0
  106. package/dist/esm/searchMiddleware.d.ts +5 -0
  107. package/dist/esm/searchMiddleware.js +42 -0
  108. package/dist/esm/searchMiddleware.js.map +1 -0
  109. package/dist/esm/searchParams.d.ts +7 -0
  110. package/dist/esm/searchParams.js +61 -0
  111. package/dist/esm/searchParams.js.map +1 -0
  112. package/dist/esm/serializer.d.ts +22 -0
  113. package/dist/esm/structuralSharing.d.ts +4 -0
  114. package/dist/esm/typePrimitives.d.ts +65 -0
  115. package/dist/esm/useLoaderData.d.ts +5 -0
  116. package/dist/esm/useLoaderDeps.d.ts +5 -0
  117. package/dist/esm/useNavigate.d.ts +3 -0
  118. package/dist/esm/useParams.d.ts +5 -0
  119. package/dist/esm/useRouteContext.d.ts +9 -0
  120. package/dist/esm/useSearch.d.ts +5 -0
  121. package/dist/esm/utils.d.ts +105 -0
  122. package/dist/esm/utils.js +160 -0
  123. package/dist/esm/utils.js.map +1 -0
  124. package/dist/esm/validators.d.ts +51 -0
  125. package/package.json +36 -32
  126. package/src/Matches.ts +239 -0
  127. package/src/RouterProvider.ts +50 -0
  128. package/src/defer.ts +52 -0
  129. package/src/fileRoute.ts +140 -0
  130. package/src/history.ts +9 -0
  131. package/src/index.ts +421 -19
  132. package/src/link.ts +580 -286
  133. package/src/location.ts +13 -0
  134. package/src/manifest.ts +32 -0
  135. package/src/not-found.ts +29 -0
  136. package/src/path.ts +425 -49
  137. package/src/qss.ts +70 -41
  138. package/src/redirect.ts +100 -0
  139. package/src/root.ts +2 -0
  140. package/src/route.ts +1679 -228
  141. package/src/routeInfo.ts +224 -217
  142. package/src/router.ts +3073 -1033
  143. package/src/scroll-restoration.ts +340 -0
  144. package/src/searchMiddleware.ts +54 -0
  145. package/src/searchParams.ts +43 -20
  146. package/src/serializer.ts +32 -0
  147. package/src/structuralSharing.ts +7 -0
  148. package/src/typePrimitives.ts +181 -0
  149. package/src/useLoaderData.ts +20 -0
  150. package/src/useLoaderDeps.ts +13 -0
  151. package/src/useNavigate.ts +13 -0
  152. package/src/useParams.ts +20 -0
  153. package/src/useRouteContext.ts +39 -0
  154. package/src/useSearch.ts +20 -0
  155. package/src/utils.ts +369 -75
  156. package/src/validators.ts +121 -0
  157. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -33
  158. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  159. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js +0 -33
  160. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
  161. package/build/cjs/node_modules/history/index.js +0 -815
  162. package/build/cjs/node_modules/history/index.js.map +0 -1
  163. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +0 -30
  164. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js.map +0 -1
  165. package/build/cjs/packages/router-core/src/index.js +0 -59
  166. package/build/cjs/packages/router-core/src/index.js.map +0 -1
  167. package/build/cjs/packages/router-core/src/path.js +0 -222
  168. package/build/cjs/packages/router-core/src/path.js.map +0 -1
  169. package/build/cjs/packages/router-core/src/qss.js +0 -71
  170. package/build/cjs/packages/router-core/src/qss.js.map +0 -1
  171. package/build/cjs/packages/router-core/src/route.js +0 -161
  172. package/build/cjs/packages/router-core/src/route.js.map +0 -1
  173. package/build/cjs/packages/router-core/src/routeConfig.js +0 -69
  174. package/build/cjs/packages/router-core/src/routeConfig.js.map +0 -1
  175. package/build/cjs/packages/router-core/src/routeMatch.js +0 -266
  176. package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
  177. package/build/cjs/packages/router-core/src/router.js +0 -812
  178. package/build/cjs/packages/router-core/src/router.js.map +0 -1
  179. package/build/cjs/packages/router-core/src/searchParams.js +0 -70
  180. package/build/cjs/packages/router-core/src/searchParams.js.map +0 -1
  181. package/build/cjs/packages/router-core/src/utils.js +0 -125
  182. package/build/cjs/packages/router-core/src/utils.js.map +0 -1
  183. package/build/esm/index.js +0 -2480
  184. package/build/esm/index.js.map +0 -1
  185. package/build/stats-html.html +0 -4034
  186. package/build/stats-react.json +0 -499
  187. package/build/types/index.d.ts +0 -619
  188. package/build/umd/index.development.js +0 -2514
  189. package/build/umd/index.development.js.map +0 -1
  190. package/build/umd/index.production.js +0 -12
  191. package/build/umd/index.production.js.map +0 -1
  192. package/src/frameworks.ts +0 -12
  193. package/src/routeConfig.ts +0 -495
  194. package/src/routeMatch.ts +0 -374
package/src/link.ts CHANGED
@@ -1,319 +1,613 @@
1
- import { AnyPathParams } from './routeConfig'
2
- import {
3
- AnyAllRouteInfo,
4
- DefaultAllRouteInfo,
5
- RouteInfoByPath,
1
+ import type { HistoryState, ParsedHistoryState } from '@tanstack/history'
2
+ import type {
3
+ AllParams,
4
+ CatchAllPaths,
5
+ CurrentPath,
6
+ FullSearchSchema,
7
+ FullSearchSchemaInput,
8
+ ParentPath,
9
+ RouteByPath,
10
+ RouteByToPath,
11
+ RoutePaths,
12
+ RouteToPath,
13
+ ToPath,
6
14
  } from './routeInfo'
7
- import { Location } from './router'
8
- import { Expand, NoInfer, PickAsRequired, PickRequired, Updater } from './utils'
9
-
10
- export type LinkInfo =
11
- | {
12
- type: 'external'
13
- href: string
14
- }
15
- | {
16
- type: 'internal'
17
- next: Location
18
- handleFocus: (e: any) => void
19
- handleClick: (e: any) => void
20
- handleEnter: (e: any) => void
21
- handleLeave: (e: any) => void
22
- isActive: boolean
23
- disabled?: boolean
24
- }
25
-
26
- type StartsWith<A, B> = A extends `${B extends string ? B : never}${infer _}`
27
- ? true
28
- : false
29
-
30
- type CleanPath<T extends string> = T extends `${infer L}//${infer R}`
31
- ? CleanPath<`${CleanPath<L>}/${CleanPath<R>}`>
32
- : T extends `${infer L}//`
33
- ? `${CleanPath<L>}/`
34
- : T extends `//${infer L}`
35
- ? `/${CleanPath<L>}`
15
+ import type {
16
+ AnyRouter,
17
+ RegisteredRouter,
18
+ ViewTransitionOptions,
19
+ } from './router'
20
+ import type {
21
+ ConstrainLiteral,
22
+ Expand,
23
+ MakeDifferenceOptional,
24
+ NoInfer,
25
+ NonNullableUpdater,
26
+ Updater,
27
+ } from './utils'
28
+ import type { ParsedLocation } from './location'
29
+
30
+ export type IsRequiredParams<TParams> =
31
+ Record<never, never> extends TParams ? never : true
32
+
33
+ export type ParsePathParams<T extends string, TAcc = never> = T &
34
+ `${string}$${string}` extends never
35
+ ? TAcc
36
+ : T extends `${string}$${infer TPossiblyParam}`
37
+ ? TPossiblyParam extends ''
38
+ ? TAcc
39
+ : TPossiblyParam & `${string}/${string}` extends never
40
+ ? TPossiblyParam | TAcc
41
+ : TPossiblyParam extends `${infer TParam}/${infer TRest}`
42
+ ? ParsePathParams<TRest, TParam extends '' ? TAcc : TParam | TAcc>
43
+ : never
44
+ : TAcc
45
+
46
+ export type AddTrailingSlash<T> = T extends `${string}/` ? T : `${T & string}/`
47
+
48
+ export type RemoveTrailingSlashes<T> = T & `${string}/` extends never
49
+ ? T
50
+ : T extends `${infer R}/`
51
+ ? R
52
+ : T
53
+
54
+ export type AddLeadingSlash<T> = T & `/${string}` extends never
55
+ ? `/${T & string}`
36
56
  : T
37
57
 
38
- export type Split<S, TIncludeTrailingSlash = true> = S extends unknown
39
- ? string extends S
40
- ? string[]
41
- : S extends string
42
- ? CleanPath<S> extends ''
43
- ? []
44
- : TIncludeTrailingSlash extends true
45
- ? CleanPath<S> extends `${infer T}/`
46
- ? [...Split<T>, '/']
47
- : CleanPath<S> extends `/${infer U}`
48
- ? Split<U>
49
- : CleanPath<S> extends `${infer T}/${infer U}`
50
- ? [...Split<T>, ...Split<U>]
51
- : [S]
52
- : CleanPath<S> extends `${infer T}/${infer U}`
53
- ? [...Split<T>, ...Split<U>]
54
- : S extends string
55
- ? [S]
56
- : never
57
- : never
58
- : never
58
+ export type RemoveLeadingSlashes<T> = T & `/${string}` extends never
59
+ ? T
60
+ : T extends `/${infer R}`
61
+ ? R
62
+ : T
63
+
64
+ type JoinPath<TLeft extends string, TRight extends string> = TRight extends ''
65
+ ? TLeft
66
+ : TLeft extends ''
67
+ ? TRight
68
+ : `${RemoveTrailingSlashes<TLeft>}/${RemoveLeadingSlashes<TRight>}`
69
+
70
+ type RemoveLastSegment<
71
+ T extends string,
72
+ TAcc extends string = '',
73
+ > = T extends `${infer TSegment}/${infer TRest}`
74
+ ? TRest & `${string}/${string}` extends never
75
+ ? TRest extends ''
76
+ ? TAcc
77
+ : `${TAcc}${TSegment}`
78
+ : RemoveLastSegment<TRest, `${TAcc}${TSegment}/`>
79
+ : TAcc
80
+
81
+ export type ResolveCurrentPath<
82
+ TFrom extends string,
83
+ TTo extends string,
84
+ > = TTo extends '.'
85
+ ? TFrom
86
+ : TTo extends './'
87
+ ? AddTrailingSlash<TFrom>
88
+ : TTo & `./${string}` extends never
89
+ ? never
90
+ : TTo extends `./${infer TRest}`
91
+ ? AddLeadingSlash<JoinPath<TFrom, TRest>>
92
+ : never
93
+
94
+ export type ResolveParentPath<
95
+ TFrom extends string,
96
+ TTo extends string,
97
+ > = TTo extends '../' | '..'
98
+ ? TFrom extends '' | '/'
99
+ ? never
100
+ : AddLeadingSlash<RemoveLastSegment<TFrom>>
101
+ : TTo & `../${string}` extends never
102
+ ? AddLeadingSlash<JoinPath<TFrom, TTo>>
103
+ : TFrom extends '' | '/'
104
+ ? never
105
+ : TTo extends `../${infer ToRest}`
106
+ ? ResolveParentPath<RemoveLastSegment<TFrom>, ToRest>
107
+ : AddLeadingSlash<JoinPath<TFrom, TTo>>
108
+
109
+ export type ResolveRelativePath<TFrom, TTo = '.'> = string extends TFrom
110
+ ? TTo
111
+ : string extends TTo
112
+ ? TFrom
113
+ : undefined extends TTo
114
+ ? TFrom
115
+ : TTo extends string
116
+ ? TFrom extends string
117
+ ? TTo extends `/${string}`
118
+ ? TTo
119
+ : TTo extends `..${string}`
120
+ ? ResolveParentPath<TFrom, TTo>
121
+ : TTo extends `.${string}`
122
+ ? ResolveCurrentPath<TFrom, TTo>
123
+ : AddLeadingSlash<JoinPath<TFrom, TTo>>
124
+ : never
125
+ : never
59
126
 
60
- export type ParsePathParams<T extends string> = Split<T>[number] extends infer U
61
- ? U extends `:${infer V}`
62
- ? V
127
+ export type FindDescendantToPaths<
128
+ TRouter extends AnyRouter,
129
+ TPrefix extends string,
130
+ > = `${TPrefix}/${string}` & RouteToPath<TRouter>
131
+
132
+ export type InferDescendantToPaths<
133
+ TRouter extends AnyRouter,
134
+ TPrefix extends string,
135
+ TPaths = FindDescendantToPaths<TRouter, TPrefix>,
136
+ > = TPaths extends `${TPrefix}/`
137
+ ? never
138
+ : TPaths extends `${TPrefix}/${infer TRest}`
139
+ ? TRest
63
140
  : never
64
- : never
65
141
 
66
- type Join<T> = T extends []
67
- ? ''
68
- : T extends [infer L extends string]
69
- ? L
70
- : T extends [infer L extends string, ...infer Tail extends [...string[]]]
71
- ? CleanPath<`${L}/${Join<Tail>}`>
72
- : never
142
+ export type RelativeToPath<
143
+ TRouter extends AnyRouter,
144
+ TTo extends string,
145
+ TResolvedPath extends string,
146
+ > =
147
+ | (TResolvedPath & RouteToPath<TRouter> extends never
148
+ ? never
149
+ : ToPath<TRouter, TTo>)
150
+ | `${RemoveTrailingSlashes<TTo>}/${InferDescendantToPaths<TRouter, RemoveTrailingSlashes<TResolvedPath>>}`
151
+
152
+ export type RelativeToParentPath<
153
+ TRouter extends AnyRouter,
154
+ TFrom extends string,
155
+ TTo extends string,
156
+ TResolvedPath extends string = ResolveRelativePath<TFrom, TTo>,
157
+ > =
158
+ | RelativeToPath<TRouter, TTo, TResolvedPath>
159
+ | (TTo extends `${string}..` | `${string}../`
160
+ ? TResolvedPath extends '/' | ''
161
+ ? never
162
+ : FindDescendantToPaths<
163
+ TRouter,
164
+ RemoveTrailingSlashes<TResolvedPath>
165
+ > extends never
166
+ ? never
167
+ : `${RemoveTrailingSlashes<TTo>}/${ParentPath<TRouter>}`
168
+ : never)
169
+
170
+ export type RelativeToCurrentPath<
171
+ TRouter extends AnyRouter,
172
+ TFrom extends string,
173
+ TTo extends string,
174
+ TResolvedPath extends string = ResolveRelativePath<TFrom, TTo>,
175
+ > = RelativeToPath<TRouter, TTo, TResolvedPath> | CurrentPath<TRouter>
176
+
177
+ export type AbsoluteToPath<TRouter extends AnyRouter, TFrom extends string> =
178
+ | (string extends TFrom
179
+ ? CurrentPath<TRouter>
180
+ : TFrom extends `/`
181
+ ? never
182
+ : CurrentPath<TRouter>)
183
+ | (string extends TFrom
184
+ ? ParentPath<TRouter>
185
+ : TFrom extends `/`
186
+ ? never
187
+ : ParentPath<TRouter>)
188
+ | RouteToPath<TRouter>
189
+ | (TFrom extends '/'
190
+ ? never
191
+ : string extends TFrom
192
+ ? never
193
+ : InferDescendantToPaths<TRouter, RemoveTrailingSlashes<TFrom>>)
73
194
 
74
195
  export type RelativeToPathAutoComplete<
75
- AllPaths extends string,
196
+ TRouter extends AnyRouter,
76
197
  TFrom extends string,
77
198
  TTo extends string,
78
- SplitPaths extends string[] = Split<AllPaths, false>,
79
- > = TTo extends `..${infer _}`
80
- ? SplitPaths extends [
81
- ...Split<ResolveRelativePath<TFrom, TTo>, false>,
82
- ...infer TToRest,
83
- ]
84
- ? `${CleanPath<
85
- Join<
86
- [
87
- ...Split<TTo, false>,
88
- ...(
89
- | TToRest
90
- | (Split<
91
- ResolveRelativePath<TFrom, TTo>,
92
- false
93
- >['length'] extends 1
94
- ? never
95
- : ['../'])
96
- ),
97
- ]
98
- >
99
- >}`
100
- : never
101
- : TTo extends `./${infer RestTTo}`
102
- ? SplitPaths extends [
103
- ...Split<TFrom, false>,
104
- ...Split<RestTTo, false>,
105
- ...infer RestPath,
106
- ]
107
- ? `${TTo}${Join<RestPath>}`
108
- : never
109
- : './' | '../' | AllPaths
110
-
111
- export type NavigateOptionsAbsolute<
112
- TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
113
- TFrom extends ValidFromPath<TAllRouteInfo> = '/',
114
- TTo extends string = '.',
115
- > = ToOptions<TAllRouteInfo, TFrom, TTo> & {
116
- // Whether to replace the current history stack instead of pushing a new one
199
+ > = string extends TTo
200
+ ? string
201
+ : string extends TFrom
202
+ ? AbsoluteToPath<TRouter, TFrom>
203
+ : TTo & `..${string}` extends never
204
+ ? TTo & `.${string}` extends never
205
+ ? AbsoluteToPath<TRouter, TFrom>
206
+ : RelativeToCurrentPath<TRouter, TFrom, TTo>
207
+ : RelativeToParentPath<TRouter, TFrom, TTo>
208
+
209
+ export type NavigateOptions<
210
+ TRouter extends AnyRouter = RegisteredRouter,
211
+ TFrom extends string = string,
212
+ TTo extends string | undefined = '.',
213
+ TMaskFrom extends string = TFrom,
214
+ TMaskTo extends string = '.',
215
+ > = ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & NavigateOptionProps
216
+
217
+ /**
218
+ * The NavigateOptions type is used to describe the options that can be used when describing a navigation action in TanStack Router.
219
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType)
220
+ */
221
+ export interface NavigateOptionProps {
222
+ /**
223
+ * If set to `true`, the router will scroll the element with an id matching the hash into view with default `ScrollIntoViewOptions`.
224
+ * If set to `false`, the router will not scroll the element with an id matching the hash into view.
225
+ * If set to `ScrollIntoViewOptions`, the router will scroll the element with an id matching the hash into view with the provided options.
226
+ * @default true
227
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#hashscrollintoview)
228
+ * @see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView)
229
+ */
230
+ hashScrollIntoView?: boolean | ScrollIntoViewOptions
231
+ /**
232
+ * `replace` is a boolean that determines whether the navigation should replace the current history entry or push a new one.
233
+ * @default false
234
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#replace)
235
+ */
117
236
  replace?: boolean
237
+ /**
238
+ * Defaults to `true` so that the scroll position will be reset to 0,0 after the location is committed to the browser history.
239
+ * If `false`, the scroll position will not be reset to 0,0 after the location is committed to history.
240
+ * @default true
241
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#resetscroll)
242
+ */
243
+ resetScroll?: boolean
244
+ /** @deprecated All navigations now use startTransition under the hood */
245
+ startTransition?: boolean
246
+ /**
247
+ * If set to `true`, the router will wrap the resulting navigation in a `document.startViewTransition()` call.
248
+ * If `ViewTransitionOptions`, route navigations will be called using `document.startViewTransition({update, types})`
249
+ * where `types` will be the strings array passed with `ViewTransitionOptions["types"]`.
250
+ * If the browser does not support viewTransition types, the navigation will fall back to normal `document.startTransition()`, same as if `true` was passed.
251
+ *
252
+ * If the browser does not support this api, this option will be ignored.
253
+ * @default false
254
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#viewtransition)
255
+ * @see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition)
256
+ * @see [Google](https://developer.chrome.com/docs/web-platform/view-transitions/same-document#view-transition-types)
257
+ */
258
+ viewTransition?: boolean | ViewTransitionOptions
259
+ /**
260
+ * If `true`, navigation will ignore any blockers that might prevent it.
261
+ * @default false
262
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#ignoreblocker)
263
+ */
264
+ ignoreBlocker?: boolean
265
+ /**
266
+ * If `true`, navigation to a route inside of router will trigger a full page load instead of the traditional SPA navigation.
267
+ * @default false
268
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#reloaddocument)
269
+ */
270
+ reloadDocument?: boolean
271
+ /**
272
+ * This can be used instead of `to` to navigate to a fully built href, e.g. pointing to an external target.
273
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#href)
274
+ */
275
+ href?: string
118
276
  }
119
277
 
120
278
  export type ToOptions<
121
- TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
122
- TFrom extends ValidFromPath<TAllRouteInfo> = '/',
123
- TTo extends string = '.',
124
- TResolvedTo = ResolveRelativePath<TFrom, NoInfer<TTo>>,
125
- > = {
126
- to?: ToPathOption<TAllRouteInfo, TFrom, TTo>
127
- // The new has string or a function to update it
128
- hash?: Updater<string>
129
- // The source route path. This is automatically set when using route-level APIs, but for type-safe relative routing on the router itself, this is required
130
- from?: TFrom
131
- // // When using relative route paths, this option forces resolution from the current path, instead of the route API's path or `from` path
132
- // fromCurrent?: boolean
133
- } & CheckPath<TAllRouteInfo, NoInfer<TResolvedTo>, {}> &
134
- SearchParamOptions<TAllRouteInfo, TFrom, TResolvedTo> &
135
- PathParamOptions<TAllRouteInfo, TFrom, TResolvedTo>
136
-
137
- type SearchParamOptions<
138
- TAllRouteInfo extends AnyAllRouteInfo,
279
+ TRouter extends AnyRouter = RegisteredRouter,
280
+ TFrom extends string = string,
281
+ TTo extends string | undefined = '.',
282
+ TMaskFrom extends string = TFrom,
283
+ TMaskTo extends string = '.',
284
+ > = ToSubOptions<TRouter, TFrom, TTo> & MaskOptions<TRouter, TMaskFrom, TMaskTo>
285
+
286
+ export interface MaskOptions<
287
+ in out TRouter extends AnyRouter,
288
+ in out TMaskFrom extends string,
289
+ in out TMaskTo extends string,
290
+ > {
291
+ _fromLocation?: ParsedLocation
292
+ mask?: ToMaskOptions<TRouter, TMaskFrom, TMaskTo>
293
+ }
294
+
295
+ export type ToMaskOptions<
296
+ TRouter extends AnyRouter = RegisteredRouter,
297
+ TMaskFrom extends string = string,
298
+ TMaskTo extends string = '.',
299
+ > = ToSubOptions<TRouter, TMaskFrom, TMaskTo> & {
300
+ unmaskOnReload?: boolean
301
+ }
302
+
303
+ export type ToSubOptions<
304
+ TRouter extends AnyRouter = RegisteredRouter,
305
+ TFrom extends string = string,
306
+ TTo extends string | undefined = '.',
307
+ > = ToSubOptionsProps<TRouter, TFrom, TTo> &
308
+ SearchParamOptions<TRouter, TFrom, TTo> &
309
+ PathParamOptions<TRouter, TFrom, TTo>
310
+
311
+ export interface RequiredToOptions<
312
+ in out TRouter extends AnyRouter,
313
+ in out TFrom extends string,
314
+ in out TTo extends string | undefined,
315
+ > {
316
+ to: ToPathOption<TRouter, TFrom, TTo> & {}
317
+ }
318
+
319
+ export interface OptionalToOptions<
320
+ in out TRouter extends AnyRouter,
321
+ in out TFrom extends string,
322
+ in out TTo extends string | undefined,
323
+ > {
324
+ to?: ToPathOption<TRouter, TFrom, TTo> & {}
325
+ }
326
+
327
+ export type MakeToRequired<
328
+ TRouter extends AnyRouter,
329
+ TFrom extends string,
330
+ TTo extends string | undefined,
331
+ > = string extends TFrom
332
+ ? string extends TTo
333
+ ? OptionalToOptions<TRouter, TFrom, TTo>
334
+ : TTo & CatchAllPaths<TRouter> extends never
335
+ ? RequiredToOptions<TRouter, TFrom, TTo>
336
+ : OptionalToOptions<TRouter, TFrom, TTo>
337
+ : OptionalToOptions<TRouter, TFrom, TTo>
338
+
339
+ export type ToSubOptionsProps<
340
+ TRouter extends AnyRouter = RegisteredRouter,
341
+ TFrom extends RoutePaths<TRouter['routeTree']> | string = string,
342
+ TTo extends string | undefined = '.',
343
+ > = MakeToRequired<TRouter, TFrom, TTo> & {
344
+ hash?: true | Updater<string>
345
+ state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>
346
+ from?: FromPathOption<TRouter, TFrom> & {}
347
+ }
348
+
349
+ export type ParamsReducerFn<
350
+ in out TRouter extends AnyRouter,
351
+ in out TParamVariant extends ParamVariant,
352
+ in out TFrom,
353
+ in out TTo,
354
+ > = (
355
+ current: Expand<ResolveFromParams<TRouter, TParamVariant, TFrom>>,
356
+ ) => Expand<ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>>
357
+
358
+ type ParamsReducer<
359
+ TRouter extends AnyRouter,
360
+ TParamVariant extends ParamVariant,
139
361
  TFrom,
140
362
  TTo,
141
- TFromSchema = RouteInfoByPath<TAllRouteInfo, TFrom>['fullSearchSchema'],
142
- TToSchema = RouteInfoByPath<TAllRouteInfo, TTo>['fullSearchSchema'],
143
- > = StartsWith<TFrom, TTo> extends true // If the next route search extend or cover the from route, params will be optional
144
- ? {
145
- search?: SearchReducer<TFromSchema, TToSchema>
146
- }
147
- : // Optional search params? Allow it
148
- keyof PickRequired<TToSchema> extends never
149
- ? {
150
- search?: SearchReducer<TFromSchema, TToSchema>
151
- }
152
- : {
153
- // Must have required search params, enforce it
154
- search: SearchReducer<TFromSchema, TToSchema>
155
- }
156
-
157
- type SearchReducer<TFrom, TTo> =
158
- | { [TKey in keyof TTo]: TTo[TKey] }
159
- | ((current: TFrom) => TTo)
160
-
161
- type PathParamOptions<
162
- TAllRouteInfo extends AnyAllRouteInfo,
363
+ > =
364
+ | Expand<ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>>
365
+ | (ParamsReducerFn<TRouter, TParamVariant, TFrom, TTo> & {})
366
+
367
+ type ParamVariant = 'PATH' | 'SEARCH'
368
+
369
+ export type ResolveRoute<
370
+ TRouter extends AnyRouter,
371
+ TFrom,
372
+ TTo,
373
+ TPath = ResolveRelativePath<TFrom, TTo>,
374
+ > = TPath extends string
375
+ ? TFrom extends TPath
376
+ ? RouteByPath<TRouter['routeTree'], TPath>
377
+ : RouteByToPath<TRouter, TPath>
378
+ : never
379
+
380
+ type ResolveFromParamType<TParamVariant extends ParamVariant> =
381
+ TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchema'
382
+
383
+ type ResolveFromAllParams<
384
+ TRouter extends AnyRouter,
385
+ TParamVariant extends ParamVariant,
386
+ > = TParamVariant extends 'PATH'
387
+ ? AllParams<TRouter['routeTree']>
388
+ : FullSearchSchema<TRouter['routeTree']>
389
+
390
+ type ResolveFromParams<
391
+ TRouter extends AnyRouter,
392
+ TParamVariant extends ParamVariant,
393
+ TFrom,
394
+ > = string extends TFrom
395
+ ? ResolveFromAllParams<TRouter, TParamVariant>
396
+ : RouteByPath<
397
+ TRouter['routeTree'],
398
+ TFrom
399
+ >['types'][ResolveFromParamType<TParamVariant>]
400
+
401
+ type ResolveToParamType<TParamVariant extends ParamVariant> =
402
+ TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchemaInput'
403
+
404
+ type ResolveAllToParams<
405
+ TRouter extends AnyRouter,
406
+ TParamVariant extends ParamVariant,
407
+ > = TParamVariant extends 'PATH'
408
+ ? AllParams<TRouter['routeTree']>
409
+ : FullSearchSchemaInput<TRouter['routeTree']>
410
+
411
+ export type ResolveToParams<
412
+ TRouter extends AnyRouter,
413
+ TParamVariant extends ParamVariant,
163
414
  TFrom,
164
415
  TTo,
165
- TFromParams = RouteInfoByPath<TAllRouteInfo, TFrom>['allParams'],
166
- TToParams = RouteInfoByPath<TAllRouteInfo, TTo>['allParams'],
167
416
  > =
168
- // If the next routes params extend or cover the from route, params will be optional
169
- StartsWith<TFrom, TTo> extends true
170
- ? {
171
- params?: ParamsReducer<TFromParams, TToParams>
172
- }
173
- : // If the next route doesn't have params, warn if any have been passed
174
- AnyPathParams extends TToParams
175
- ? {
176
- params?: ParamsReducer<TFromParams, Record<string, never>>
177
- }
178
- : // If the next route has params, enforce them
179
- {
180
- params: ParamsReducer<TFromParams, TToParams>
181
- }
182
-
183
- type ParamsReducer<TFrom, TTo> = TTo | ((current: TFrom) => TTo)
417
+ ResolveRelativePath<TFrom, TTo> extends infer TPath
418
+ ? undefined extends TPath
419
+ ? never
420
+ : string extends TPath
421
+ ? ResolveAllToParams<TRouter, TParamVariant>
422
+ : TPath extends CatchAllPaths<TRouter>
423
+ ? ResolveAllToParams<TRouter, TParamVariant>
424
+ : ResolveRoute<
425
+ TRouter,
426
+ TFrom,
427
+ TTo
428
+ >['types'][ResolveToParamType<TParamVariant>]
429
+ : never
184
430
 
185
- export type ToPathOption<
186
- TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
187
- TFrom extends ValidFromPath<TAllRouteInfo> = '/',
188
- TTo extends string = '.',
431
+ type ResolveRelativeToParams<
432
+ TRouter extends AnyRouter,
433
+ TParamVariant extends ParamVariant,
434
+ TFrom,
435
+ TTo,
436
+ TToParams = ResolveToParams<TRouter, TParamVariant, TFrom, TTo>,
437
+ > = TParamVariant extends 'SEARCH'
438
+ ? TToParams
439
+ : string extends TFrom
440
+ ? TToParams
441
+ : MakeDifferenceOptional<
442
+ ResolveFromParams<TRouter, TParamVariant, TFrom>,
443
+ TToParams
444
+ >
445
+
446
+ export interface MakeOptionalSearchParams<
447
+ in out TRouter extends AnyRouter,
448
+ in out TFrom,
449
+ in out TTo,
450
+ > {
451
+ search?: true | (ParamsReducer<TRouter, 'SEARCH', TFrom, TTo> & {})
452
+ }
453
+
454
+ export interface MakeOptionalPathParams<
455
+ in out TRouter extends AnyRouter,
456
+ in out TFrom,
457
+ in out TTo,
458
+ > {
459
+ params?: true | (ParamsReducer<TRouter, 'PATH', TFrom, TTo> & {})
460
+ }
461
+
462
+ type MakeRequiredParamsReducer<
463
+ TRouter extends AnyRouter,
464
+ TParamVariant extends ParamVariant,
465
+ TFrom,
466
+ TTo,
189
467
  > =
190
- | TTo
191
- | RelativeToPathAutoComplete<
192
- TAllRouteInfo['routePaths'],
193
- NoInfer<TFrom> extends string ? NoInfer<TFrom> : '',
194
- NoInfer<TTo> & string
195
- >
196
-
197
- export type ToIdOption<
198
- TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
199
- TFrom extends ValidFromPath<TAllRouteInfo> = '/',
200
- TTo extends string = '.',
468
+ | (string extends TFrom
469
+ ? never
470
+ : ResolveFromParams<
471
+ TRouter,
472
+ TParamVariant,
473
+ TFrom
474
+ > extends ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>
475
+ ? true
476
+ : never)
477
+ | (ParamsReducer<TRouter, TParamVariant, TFrom, TTo> & {})
478
+
479
+ export interface MakeRequiredPathParams<
480
+ in out TRouter extends AnyRouter,
481
+ in out TFrom,
482
+ in out TTo,
483
+ > {
484
+ params: MakeRequiredParamsReducer<TRouter, 'PATH', TFrom, TTo> & {}
485
+ }
486
+
487
+ export interface MakeRequiredSearchParams<
488
+ in out TRouter extends AnyRouter,
489
+ in out TFrom,
490
+ in out TTo,
491
+ > {
492
+ search: MakeRequiredParamsReducer<TRouter, 'SEARCH', TFrom, TTo> & {}
493
+ }
494
+
495
+ export type IsRequired<
496
+ TRouter extends AnyRouter,
497
+ TParamVariant extends ParamVariant,
498
+ TFrom,
499
+ TTo,
201
500
  > =
202
- | TTo
203
- | RelativeToPathAutoComplete<
204
- TAllRouteInfo['routeIds'],
205
- NoInfer<TFrom> extends string ? NoInfer<TFrom> : '',
206
- NoInfer<TTo> & string
207
- >
208
-
209
- interface ActiveOptions {
501
+ ResolveRelativePath<TFrom, TTo> extends infer TPath
502
+ ? undefined extends TPath
503
+ ? never
504
+ : TPath extends CatchAllPaths<TRouter>
505
+ ? never
506
+ : IsRequiredParams<
507
+ ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>
508
+ >
509
+ : never
510
+
511
+ export type SearchParamOptions<TRouter extends AnyRouter, TFrom, TTo> =
512
+ IsRequired<TRouter, 'SEARCH', TFrom, TTo> extends never
513
+ ? MakeOptionalSearchParams<TRouter, TFrom, TTo>
514
+ : MakeRequiredSearchParams<TRouter, TFrom, TTo>
515
+
516
+ export type PathParamOptions<TRouter extends AnyRouter, TFrom, TTo> =
517
+ IsRequired<TRouter, 'PATH', TFrom, TTo> extends never
518
+ ? MakeOptionalPathParams<TRouter, TFrom, TTo>
519
+ : MakeRequiredPathParams<TRouter, TFrom, TTo>
520
+
521
+ export type ToPathOption<
522
+ TRouter extends AnyRouter = AnyRouter,
523
+ TFrom extends string = string,
524
+ TTo extends string | undefined = string,
525
+ > = ConstrainLiteral<
526
+ TTo,
527
+ RelativeToPathAutoComplete<
528
+ TRouter,
529
+ NoInfer<TFrom> extends string ? NoInfer<TFrom> : '',
530
+ NoInfer<TTo> & string
531
+ >
532
+ >
533
+
534
+ export type FromPathOption<TRouter extends AnyRouter, TFrom> = ConstrainLiteral<
535
+ TFrom,
536
+ RoutePaths<TRouter['routeTree']>
537
+ >
538
+
539
+ /**
540
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/navigation#active-options)
541
+ */
542
+ export interface ActiveOptions {
543
+ /**
544
+ * If true, the link will be active if the current route matches the `to` route path exactly (no children routes)
545
+ * @default false
546
+ */
210
547
  exact?: boolean
548
+ /**
549
+ * If true, the link will only be active if the current URL hash matches the `hash` prop
550
+ * @default false
551
+ */
211
552
  includeHash?: boolean
553
+ /**
554
+ * If true, the link will only be active if the current URL search params inclusively match the `search` prop
555
+ * @default true
556
+ */
557
+ includeSearch?: boolean
558
+ /**
559
+ * This modifies the `includeSearch` behavior.
560
+ * If true, properties in `search` that are explicitly `undefined` must NOT be present in the current URL search params for the link to be active.
561
+ * @default false
562
+ */
563
+ explicitUndefined?: boolean
212
564
  }
213
565
 
214
- export type LinkOptions<
215
- TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
216
- TFrom extends ValidFromPath<TAllRouteInfo> = '/',
217
- TTo extends string = '.',
218
- > = NavigateOptionsAbsolute<TAllRouteInfo, TFrom, TTo> & {
219
- // The standard anchor tag target attribute
566
+ export interface LinkOptionsProps {
567
+ /**
568
+ * The standard anchor tag target attribute
569
+ */
220
570
  target?: HTMLAnchorElement['target']
221
- // Defaults to `{ exact: false, includeHash: false }`
571
+ /**
572
+ * Configurable options to determine if the link should be considered active or not
573
+ * @default {exact:true,includeHash:true}
574
+ */
222
575
  activeOptions?: ActiveOptions
223
- // If set, will preload the linked route on hover and cache it for this many milliseconds in hopes that the user will eventually navigate there.
224
- preload?: false | 'intent'
225
- // When preloaded, the preloaded result will be considered "fresh" for this duration in milliseconds
226
- preloadMaxAge?: number
227
- // When preloaded and subsequently inactive, the preloaded result will remain in memory for this duration in milliseconds
228
- preloadGcMaxAge?: number
229
- // Delay intent preloading by this many milliseconds. If the intent exits before this delay, the preload will be cancelled.
576
+ /**
577
+ * The preloading strategy for this link
578
+ * - `false` - No preloading
579
+ * - `'intent'` - Preload the linked route on hover and cache it for this many milliseconds in hopes that the user will eventually navigate there.
580
+ * - `'viewport'` - Preload the linked route when it enters the viewport
581
+ */
582
+ preload?: false | 'intent' | 'viewport' | 'render'
583
+ /**
584
+ * When a preload strategy is set, this delays the preload by this many milliseconds.
585
+ * If the user exits the link before this delay, the preload will be cancelled.
586
+ */
230
587
  preloadDelay?: number
231
- // If true, will render the link without the href attribute
588
+ /**
589
+ * Control whether the link should be disabled or not
590
+ * If set to `true`, the link will be rendered without an `href` attribute
591
+ * @default false
592
+ */
232
593
  disabled?: boolean
594
+ /**
595
+ * When the preload strategy is set to `intent`, this controls the proximity of the link to the cursor before it is preloaded.
596
+ * If the user exits this proximity before this delay, the preload will be cancelled.
597
+ */
598
+ preloadIntentProximity?: number
233
599
  }
234
600
 
235
- export type CheckRelativePath<
236
- TAllRouteInfo extends AnyAllRouteInfo,
237
- TFrom,
238
- TTo,
239
- > = TTo extends string
240
- ? TFrom extends string
241
- ? ResolveRelativePath<TFrom, TTo> extends TAllRouteInfo['routePaths']
242
- ? {}
243
- : {
244
- Error: `${TFrom} + ${TTo} resolves to ${ResolveRelativePath<
245
- TFrom,
246
- TTo
247
- >}, which is not a valid route path.`
248
- 'Valid Route Paths': TAllRouteInfo['routePaths']
249
- }
250
- : {}
251
- : {}
252
-
253
- export type CheckPath<
254
- TAllRouteInfo extends AnyAllRouteInfo,
255
- TPath,
256
- TPass,
257
- > = Exclude<TPath, TAllRouteInfo['routePaths']> extends never
258
- ? TPass
259
- : CheckPathError<TAllRouteInfo, Exclude<TPath, TAllRouteInfo['routePaths']>>
260
-
261
- export type CheckPathError<
262
- TAllRouteInfo extends AnyAllRouteInfo,
263
- TInvalids,
264
- > = Expand<{
265
- Error: `${TInvalids extends string
266
- ? TInvalids
267
- : never} is not a valid route path.`
268
- 'Valid Route Paths': TAllRouteInfo['routePaths']
269
- }>
270
-
271
- export type CheckId<
272
- TAllRouteInfo extends AnyAllRouteInfo,
273
- TPath,
274
- TPass,
275
- > = Exclude<TPath, TAllRouteInfo['routeIds']> extends never
276
- ? TPass
277
- : CheckIdError<TAllRouteInfo, Exclude<TPath, TAllRouteInfo['routeIds']>>
278
-
279
- export type CheckIdError<
280
- TAllRouteInfo extends AnyAllRouteInfo,
281
- TInvalids,
282
- > = Expand<{
283
- Error: `${TInvalids extends string
284
- ? TInvalids
285
- : never} is not a valid route ID.`
286
- 'Valid Route IDs': TAllRouteInfo['routeIds']
287
- }>
288
-
289
- export type ResolveRelativePath<TFrom, TTo = '.'> = TFrom extends string
290
- ? TTo extends string
291
- ? TTo extends '.'
292
- ? TFrom
293
- : TTo extends `./`
294
- ? Join<[TFrom, '/']>
295
- : TTo extends `./${infer TRest}`
296
- ? ResolveRelativePath<TFrom, TRest>
297
- : TTo extends `/${infer TRest}`
298
- ? TTo
299
- : Split<TTo> extends ['..', ...infer ToRest]
300
- ? Split<TFrom> extends [...infer FromRest, infer FromTail]
301
- ? ToRest extends ['/']
302
- ? Join<[...FromRest, '/']>
303
- : ResolveRelativePath<Join<FromRest>, Join<ToRest>>
304
- : never
305
- : Split<TTo> extends ['.', ...infer ToRest]
306
- ? ToRest extends ['/']
307
- ? Join<[TFrom, '/']>
308
- : ResolveRelativePath<TFrom, Join<ToRest>>
309
- : CleanPath<Join<['/', ...Split<TFrom>, ...Split<TTo>]>>
310
- : never
311
- : never
601
+ export type LinkOptions<
602
+ TRouter extends AnyRouter = RegisteredRouter,
603
+ TFrom extends string = string,
604
+ TTo extends string | undefined = '.',
605
+ TMaskFrom extends string = TFrom,
606
+ TMaskTo extends string = '.',
607
+ > = NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & LinkOptionsProps
312
608
 
313
- export type ValidFromPath<
314
- TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
315
- > =
316
- | undefined
317
- | (string extends TAllRouteInfo['routePaths']
318
- ? string
319
- : TAllRouteInfo['routePaths'])
609
+ export type LinkCurrentTargetElement = {
610
+ preloadTimeout?: null | ReturnType<typeof setTimeout>
611
+ }
612
+
613
+ export const preloadWarning = 'Error preloading route! ☝️'