@tanstack/router-core 1.119.0 → 1.120.4-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 (51) hide show
  1. package/dist/cjs/fileRoute.d.cts +6 -2
  2. package/dist/cjs/index.cjs +4 -0
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/cjs/index.d.cts +5 -5
  5. package/dist/cjs/link.cjs.map +1 -1
  6. package/dist/cjs/link.d.cts +7 -2
  7. package/dist/cjs/path.cjs +130 -16
  8. package/dist/cjs/path.cjs.map +1 -1
  9. package/dist/cjs/path.d.cts +17 -0
  10. package/dist/cjs/redirect.cjs +19 -14
  11. package/dist/cjs/redirect.cjs.map +1 -1
  12. package/dist/cjs/redirect.d.cts +10 -8
  13. package/dist/cjs/route.cjs +12 -1
  14. package/dist/cjs/route.cjs.map +1 -1
  15. package/dist/cjs/route.d.cts +10 -11
  16. package/dist/cjs/router.cjs +227 -155
  17. package/dist/cjs/router.cjs.map +1 -1
  18. package/dist/cjs/router.d.cts +50 -7
  19. package/dist/cjs/typePrimitives.d.cts +2 -2
  20. package/dist/cjs/utils.cjs.map +1 -1
  21. package/dist/cjs/utils.d.cts +3 -1
  22. package/dist/esm/fileRoute.d.ts +6 -2
  23. package/dist/esm/index.d.ts +5 -5
  24. package/dist/esm/index.js +7 -3
  25. package/dist/esm/link.d.ts +7 -2
  26. package/dist/esm/link.js.map +1 -1
  27. package/dist/esm/path.d.ts +17 -0
  28. package/dist/esm/path.js +130 -16
  29. package/dist/esm/path.js.map +1 -1
  30. package/dist/esm/redirect.d.ts +10 -8
  31. package/dist/esm/redirect.js +20 -15
  32. package/dist/esm/redirect.js.map +1 -1
  33. package/dist/esm/route.d.ts +10 -11
  34. package/dist/esm/route.js +12 -1
  35. package/dist/esm/route.js.map +1 -1
  36. package/dist/esm/router.d.ts +50 -7
  37. package/dist/esm/router.js +230 -158
  38. package/dist/esm/router.js.map +1 -1
  39. package/dist/esm/typePrimitives.d.ts +2 -2
  40. package/dist/esm/utils.d.ts +3 -1
  41. package/dist/esm/utils.js.map +1 -1
  42. package/package.json +2 -2
  43. package/src/fileRoute.ts +90 -1
  44. package/src/index.ts +13 -3
  45. package/src/link.ts +10 -7
  46. package/src/path.ts +181 -16
  47. package/src/redirect.ts +42 -28
  48. package/src/route.ts +96 -23
  49. package/src/router.ts +332 -215
  50. package/src/typePrimitives.ts +2 -2
  51. package/src/utils.ts +20 -6
@@ -5,7 +5,7 @@ import type {
5
5
  SearchParamOptions,
6
6
  ToPathOption,
7
7
  } from './link'
8
- import type { Redirect } from './redirect'
8
+ import type { RedirectOptions } from './redirect'
9
9
  import type { RouteIds } from './routeInfo'
10
10
  import type { AnyRouter, RegisteredRouter } from './router'
11
11
  import type { UseParamsResult } from './useParams'
@@ -104,7 +104,7 @@ export type ValidateRedirectOptions<
104
104
  TDefaultFrom extends string = string,
105
105
  > = Constrain<
106
106
  TOptions,
107
- Redirect<
107
+ RedirectOptions<
108
108
  TRouter,
109
109
  InferFrom<TOptions, TDefaultFrom>,
110
110
  InferTo<TOptions>,
package/src/utils.ts CHANGED
@@ -37,12 +37,12 @@ export type DeepPartial<T> = T extends object
37
37
  }
38
38
  : T
39
39
 
40
- export type MakeDifferenceOptional<TLeft, TRight> = Omit<
41
- TRight,
42
- keyof TLeft
43
- > & {
44
- [K in keyof TLeft & keyof TRight]?: TRight[K]
45
- }
40
+ export type MakeDifferenceOptional<TLeft, TRight> = keyof TLeft &
41
+ keyof TRight extends never
42
+ ? TRight
43
+ : Omit<TRight, keyof TLeft & keyof TRight> & {
44
+ [K in keyof TLeft & keyof TRight]?: TRight[K]
45
+ }
46
46
 
47
47
  // from https://stackoverflow.com/a/53955431
48
48
  // eslint-disable-next-line @typescript-eslint/naming-convention
@@ -169,6 +169,20 @@ export type ValidateJSON<T> = ((...args: Array<any>) => any) extends T
169
169
  : 'Function is not serializable'
170
170
  : { [K in keyof T]: ValidateJSON<T[K]> }
171
171
 
172
+ export type LooseReturnType<T> = T extends (
173
+ ...args: Array<any>
174
+ ) => infer TReturn
175
+ ? TReturn
176
+ : never
177
+
178
+ export type LooseAsyncReturnType<T> = T extends (
179
+ ...args: Array<any>
180
+ ) => infer TReturn
181
+ ? TReturn extends Promise<infer TReturn>
182
+ ? TReturn
183
+ : TReturn
184
+ : never
185
+
172
186
  export function last<T>(arr: Array<T>) {
173
187
  return arr[arr.length - 1]
174
188
  }