@tanstack/react-router 0.0.1-beta.283 → 0.0.1-beta.285

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.
@@ -43,13 +43,15 @@ export type ToSubOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTr
43
43
  state?: true | NonNullableUpdater<HistoryState>;
44
44
  from?: TFrom;
45
45
  } & CheckPath<TRouteTree, NoInfer<TResolved>, {}> & SearchParamOptions<TRouteTree, TFrom, TTo, TResolved> & PathParamOptions<TRouteTree, TFrom, TResolved>;
46
- export type SearchParamOptions<TRouteTree extends AnyRoute, TFrom, TTo, TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>, TFromSearchEnsured = '/' extends TFrom ? FullSearchSchema<TRouteTree> : Expand<UnionToIntersection<PickRequired<RouteByPath<TRouteTree, TFrom>['types']['fullSearchSchema']>>>, TFromSearchOptional = Omit<FullSearchSchema<TRouteTree>, keyof TFromSearchEnsured>, TFromSearch = Expand<TFromSearchEnsured & TFromSearchOptional>, TToSearch = '' extends TTo ? FullSearchSchema<TRouteTree> : Expand<RouteByPath<TRouteTree, TResolved>['types']['fullSearchSchema']>> = keyof PickRequired<TToSearch> extends never ? {
46
+ export type SearchParamOptions<TRouteTree extends AnyRoute, TFrom, TTo, TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>, TFromSearchEnsured = '/' extends TFrom ? FullSearchSchema<TRouteTree> : Expand<PickRequired<RouteByPath<TRouteTree, TFrom>['types']['fullSearchSchema']>>, TFromSearchOptional = Omit<FullSearchSchema<TRouteTree>, keyof TFromSearchEnsured>, TFromSearch = Expand<TFromSearchEnsured & TFromSearchOptional>, TToSearch = '' extends TTo ? FullSearchSchema<TRouteTree> : Expand<RouteByPath<TRouteTree, TResolved>['types']['fullSearchSchema']>> = keyof PickRequired<TToSearch> extends never ? {
47
47
  search?: true | SearchReducer<TFromSearch, TToSearch>;
48
48
  } : {
49
49
  search: TFromSearchEnsured extends PickRequired<TToSearch> ? true | SearchReducer<TFromSearch, TToSearch> : SearchReducer<TFromSearch, TToSearch>;
50
50
  };
51
51
  type SearchReducer<TFrom, TTo> = TTo | ((current: TFrom) => TTo);
52
- export type PathParamOptions<TRouteTree extends AnyRoute, TFrom, TTo, TFromParamsEnsured = Expand<UnionToIntersection<PickRequired<RouteByPath<TRouteTree, TFrom>['types']['allParams']>>>, TFromParamsOptional = Omit<AllParams<TRouteTree>, keyof TFromParamsEnsured>, TFromParams = Expand<TFromParamsOptional & TFromParamsEnsured>, TToParams = Expand<RouteByPath<TRouteTree, TTo>['types']['allParams']>> = keyof PickRequired<TToParams> extends never ? {
52
+ export type PathParamOptions<TRouteTree extends AnyRoute, TFrom, TTo, TFromParamsEnsured = Expand<UnionToIntersection<PickRequired<RouteByPath<TRouteTree, TFrom>['types']['allParams']>>>, TFromParamsOptional = Omit<AllParams<TRouteTree>, keyof TFromParamsEnsured>, TFromParams = Expand<TFromParamsOptional & TFromParamsEnsured>, TToParams = Expand<RouteByPath<TRouteTree, TTo>['types']['allParams']>> = never extends TToParams ? {
53
+ params?: true | ParamsReducer<Partial<TFromParams>, Partial<TFromParams>>;
54
+ } : keyof PickRequired<TToParams> extends never ? {
53
55
  params?: true | ParamsReducer<TFromParams, TToParams>;
54
56
  } : {
55
57
  params: TFromParamsEnsured extends PickRequired<TToParams> ? true | ParamsReducer<TFromParams, TToParams> : ParamsReducer<TFromParams, TToParams>;
@@ -1,5 +1,5 @@
1
1
  import { AnyRoute, Route } from './route';
2
- import { Expand, UnionToIntersection } from './utils';
2
+ import { Expand, UnionToIntersection, UnionToTuple } from './utils';
3
3
  export type ParseRoute<TRouteTree extends AnyRoute> = TRouteTree | ParseRouteChildren<TRouteTree>;
4
4
  export type ParseRouteChildren<TRouteTree extends AnyRoute> = TRouteTree extends Route<any, any, any, any, any, any, any, any, any, any, any, any, any, any, infer TChildren, any> ? unknown extends TChildren ? never : TChildren extends AnyRoute[] ? {
5
5
  [TId in TChildren[number]['id'] as string]: ParseRoute<TChildren[number]>;
@@ -18,5 +18,14 @@ export type RouteByPath<TRouteTree extends AnyRoute, TPath> = Extract<ParseRoute
18
18
  fullPath: TPath;
19
19
  }>;
20
20
  export type RoutePaths<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree>['fullPath'] | '/';
21
- export type FullSearchSchema<TRouteTree extends AnyRoute> = Partial<Expand<UnionToIntersection<ParseRoute<TRouteTree>['types']['fullSearchSchema']>>>;
21
+ type UnionizeCollisions<T, U> = {
22
+ [P in keyof T & keyof U]: T[P] extends U[P] ? T[P] : T[P] | U[P];
23
+ };
24
+ type Reducer<T, U, C = UnionizeCollisions<T, U>> = C & Omit<T, keyof C> & Omit<U, keyof C>;
25
+ type Reduce<T extends any[], Result = unknown> = T extends [
26
+ infer First,
27
+ ...infer Rest
28
+ ] ? Reduce<Rest, Reducer<Result, First>> : Result;
29
+ export type FullSearchSchema<TRouteTree extends AnyRoute> = Partial<Expand<Reduce<UnionToTuple<ParseRoute<TRouteTree>['types']['fullSearchSchema']>>>>;
22
30
  export type AllParams<TRouteTree extends AnyRoute> = Expand<UnionToIntersection<ParseRoute<TRouteTree>['types']['allParams']>>;
31
+ export {};
@@ -36,6 +36,8 @@ export type PickExtract<T, U> = {
36
36
  export type PickExclude<T, U> = {
37
37
  [K in keyof T as T[K] extends U ? never : K]: T[K];
38
38
  };
39
+ type LastInUnion<U> = UnionToIntersection<U extends unknown ? (x: U) => 0 : never> extends (x: infer L) => 0 ? L : never;
40
+ export type UnionToTuple<U, Last = LastInUnion<U>> = [U] extends [never] ? [] : [...UnionToTuple<Exclude<U, Last>>, Last];
39
41
  export declare const isServer: boolean;
40
42
  export declare function last<T>(arr: T[]): T | undefined;
41
43
  export declare function functionalUpdate<TResult>(updater: Updater<TResult> | NonNullableUpdater<TResult>, previous: TResult): TResult;
@@ -64,3 +66,4 @@ export declare function useRouteContext<TRouteTree extends AnyRoute = Registered
64
66
  }): TStrict extends true ? TSelected : TSelected | undefined;
65
67
  export declare const useLayoutEffect: typeof React.useLayoutEffect;
66
68
  export declare function escapeJSON(jsonString: string): string;
69
+ export {};
@@ -771,6 +771,8 @@
771
771
  // // Using DeepMerge to merge TypeA and TypeB
772
772
  // type MergedType = Expand<AssignAll<[TypeA, TypeB, TypeC]>>
773
773
 
774
+ // from https://github.com/type-challenges/type-challenges/issues/737
775
+
774
776
  //
775
777
 
776
778
  const isServer = typeof document === 'undefined';