@sinclair/typebox 0.32.0-dev-21 → 0.32.0-dev-22

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 (155) hide show
  1. package/build/import/index.d.mts +2 -2
  2. package/build/import/type/awaited/awaited.d.mts +4 -6
  3. package/build/import/type/awaited/awaited.mjs +3 -3
  4. package/build/import/type/composite/composite.d.mts +8 -8
  5. package/build/import/type/const/const.d.mts +4 -7
  6. package/build/import/type/constructor/constructor.d.mts +4 -4
  7. package/build/import/type/deref/deref.d.mts +2 -2
  8. package/build/import/type/deref/deref.mjs +26 -36
  9. package/build/import/type/exclude/exclude-from-mapped-result.d.mts +4 -6
  10. package/build/import/type/exclude/exclude.d.mts +7 -8
  11. package/build/import/type/extends/extends-from-mapped-key.d.mts +5 -8
  12. package/build/import/type/extends/extends-from-mapped-key.mjs +3 -3
  13. package/build/import/type/extends/extends-from-mapped-result.d.mts +4 -6
  14. package/build/import/type/extends/extends.d.mts +2 -3
  15. package/build/import/type/extract/extract-from-mapped-result.d.mts +4 -6
  16. package/build/import/type/extract/extract.d.mts +8 -8
  17. package/build/import/type/function/function.d.mts +1 -1
  18. package/build/import/type/helpers/helpers.d.mts +1 -1
  19. package/build/import/type/index.d.mts +0 -1
  20. package/build/import/type/index.mjs +0 -1
  21. package/build/import/type/indexed/indexed-from-mapped-key.d.mts +5 -8
  22. package/build/import/type/indexed/indexed-from-mapped-key.mjs +3 -6
  23. package/build/import/type/indexed/indexed-property-keys.d.mts +4 -7
  24. package/build/import/type/indexed/indexed.d.mts +13 -23
  25. package/build/import/type/indexed/indexed.mjs +13 -13
  26. package/build/import/type/intersect/intersect-create.mjs +0 -1
  27. package/build/import/type/intersect/intersect-evaluated.d.mts +7 -11
  28. package/build/import/type/intersect/intersect-evaluated.mjs +12 -7
  29. package/build/import/type/intersect/intersect-type.d.mts +2 -2
  30. package/build/import/type/intersect/intersect.mjs +1 -2
  31. package/build/import/type/intrinsic/intrinsic-from-mapped-key.d.mts +7 -9
  32. package/build/import/type/intrinsic/intrinsic-from-mapped-key.mjs +3 -3
  33. package/build/import/type/intrinsic/intrinsic.d.mts +6 -8
  34. package/build/import/type/intrinsic/intrinsic.mjs +5 -3
  35. package/build/import/type/keyof/keyof-from-mapped-result.d.mts +4 -6
  36. package/build/import/type/keyof/keyof-property-keys.d.mts +9 -13
  37. package/build/import/type/keyof/keyof-property-keys.mjs +12 -9
  38. package/build/import/type/keyof/keyof.d.mts +7 -8
  39. package/build/import/type/keyof/keyof.mjs +8 -6
  40. package/build/import/type/mapped/mapped.d.mts +9 -13
  41. package/build/import/type/mapped/mapped.mjs +9 -9
  42. package/build/import/type/omit/omit-from-mapped-key.d.mts +5 -8
  43. package/build/import/type/omit/omit-from-mapped-key.mjs +3 -3
  44. package/build/import/type/omit/omit.d.mts +6 -9
  45. package/build/import/type/omit/omit.mjs +0 -1
  46. package/build/import/type/operators/operators.d.mts +16 -16
  47. package/build/import/type/operators/operators.mjs +21 -25
  48. package/build/import/type/optional/optional-from-mapped-result.d.mts +4 -6
  49. package/build/import/type/optional/optional.d.mts +3 -7
  50. package/build/import/type/partial/partial-from-mapped-result.d.mts +4 -6
  51. package/build/import/type/partial/partial.d.mts +4 -7
  52. package/build/import/type/partial/partial.mjs +6 -7
  53. package/build/import/type/pick/pick-from-mapped-key.d.mts +5 -8
  54. package/build/import/type/pick/pick-from-mapped-key.mjs +3 -3
  55. package/build/import/type/pick/pick.d.mts +4 -4
  56. package/build/import/type/readonly/readonly-from-mapped-result.d.mts +4 -6
  57. package/build/import/type/readonly/readonly.d.mts +3 -7
  58. package/build/import/type/record/record.d.mts +13 -19
  59. package/build/import/type/record/record.mjs +0 -1
  60. package/build/import/type/ref/ref.mjs +3 -0
  61. package/build/import/type/required/required-from-mapped-result.d.mts +4 -6
  62. package/build/import/type/required/required.d.mts +5 -9
  63. package/build/import/type/required/required.mjs +6 -7
  64. package/build/import/type/rest/rest.d.mts +3 -3
  65. package/build/import/type/static/static.d.mts +1 -1
  66. package/build/import/type/template-literal/finite.d.mts +3 -3
  67. package/build/import/type/template-literal/generate.d.mts +7 -8
  68. package/build/import/type/template-literal/syntax.d.mts +2 -2
  69. package/build/import/type/template-literal/syntax.mjs +2 -2
  70. package/build/import/type/transform/transform.mjs +0 -1
  71. package/build/import/type/tuple/tuple.d.mts +1 -2
  72. package/build/import/type/union/union-evaluated.d.mts +6 -10
  73. package/build/import/type/union/union-evaluated.mjs +7 -2
  74. package/build/require/index.d.ts +2 -2
  75. package/build/require/type/awaited/awaited.d.ts +4 -6
  76. package/build/require/type/awaited/awaited.js +3 -3
  77. package/build/require/type/composite/composite.d.ts +8 -8
  78. package/build/require/type/const/const.d.ts +4 -7
  79. package/build/require/type/constructor/constructor.d.ts +4 -4
  80. package/build/require/type/deref/deref.d.ts +2 -2
  81. package/build/require/type/deref/deref.js +25 -35
  82. package/build/require/type/exclude/exclude-from-mapped-result.d.ts +4 -6
  83. package/build/require/type/exclude/exclude.d.ts +7 -8
  84. package/build/require/type/extends/extends-from-mapped-key.d.ts +5 -8
  85. package/build/require/type/extends/extends-from-mapped-key.js +3 -3
  86. package/build/require/type/extends/extends-from-mapped-result.d.ts +4 -6
  87. package/build/require/type/extends/extends.d.ts +2 -3
  88. package/build/require/type/extract/extract-from-mapped-result.d.ts +4 -6
  89. package/build/require/type/extract/extract.d.ts +8 -8
  90. package/build/require/type/function/function.d.ts +1 -1
  91. package/build/require/type/helpers/helpers.d.ts +1 -1
  92. package/build/require/type/index.d.ts +0 -1
  93. package/build/require/type/index.js +0 -1
  94. package/build/require/type/indexed/indexed-from-mapped-key.d.ts +5 -8
  95. package/build/require/type/indexed/indexed-from-mapped-key.js +3 -6
  96. package/build/require/type/indexed/indexed-property-keys.d.ts +4 -7
  97. package/build/require/type/indexed/indexed.d.ts +13 -23
  98. package/build/require/type/indexed/indexed.js +13 -13
  99. package/build/require/type/intersect/intersect-create.js +0 -1
  100. package/build/require/type/intersect/intersect-evaluated.d.ts +7 -11
  101. package/build/require/type/intersect/intersect-evaluated.js +9 -4
  102. package/build/require/type/intersect/intersect-type.d.ts +2 -2
  103. package/build/require/type/intersect/intersect.js +0 -1
  104. package/build/require/type/intrinsic/intrinsic-from-mapped-key.d.ts +7 -9
  105. package/build/require/type/intrinsic/intrinsic-from-mapped-key.js +3 -3
  106. package/build/require/type/intrinsic/intrinsic.d.ts +6 -8
  107. package/build/require/type/intrinsic/intrinsic.js +5 -3
  108. package/build/require/type/keyof/keyof-from-mapped-result.d.ts +4 -6
  109. package/build/require/type/keyof/keyof-property-keys.d.ts +9 -13
  110. package/build/require/type/keyof/keyof-property-keys.js +12 -9
  111. package/build/require/type/keyof/keyof.d.ts +7 -8
  112. package/build/require/type/keyof/keyof.js +8 -6
  113. package/build/require/type/mapped/mapped.d.ts +9 -13
  114. package/build/require/type/mapped/mapped.js +9 -9
  115. package/build/require/type/omit/omit-from-mapped-key.d.ts +5 -8
  116. package/build/require/type/omit/omit-from-mapped-key.js +3 -3
  117. package/build/require/type/omit/omit.d.ts +6 -9
  118. package/build/require/type/omit/omit.js +0 -1
  119. package/build/require/type/operators/operators.d.ts +16 -16
  120. package/build/require/type/operators/operators.js +21 -25
  121. package/build/require/type/optional/optional-from-mapped-result.d.ts +4 -6
  122. package/build/require/type/optional/optional.d.ts +3 -7
  123. package/build/require/type/partial/partial-from-mapped-result.d.ts +4 -6
  124. package/build/require/type/partial/partial.d.ts +4 -7
  125. package/build/require/type/partial/partial.js +6 -7
  126. package/build/require/type/pick/pick-from-mapped-key.d.ts +5 -8
  127. package/build/require/type/pick/pick-from-mapped-key.js +3 -3
  128. package/build/require/type/pick/pick.d.ts +4 -4
  129. package/build/require/type/readonly/readonly-from-mapped-result.d.ts +4 -6
  130. package/build/require/type/readonly/readonly.d.ts +3 -7
  131. package/build/require/type/record/record.d.ts +13 -19
  132. package/build/require/type/record/record.js +0 -1
  133. package/build/require/type/ref/ref.js +3 -0
  134. package/build/require/type/required/required-from-mapped-result.d.ts +4 -6
  135. package/build/require/type/required/required.d.ts +5 -9
  136. package/build/require/type/required/required.js +6 -7
  137. package/build/require/type/rest/rest.d.ts +3 -3
  138. package/build/require/type/static/static.d.ts +1 -1
  139. package/build/require/type/template-literal/finite.d.ts +3 -3
  140. package/build/require/type/template-literal/generate.d.ts +7 -8
  141. package/build/require/type/template-literal/syntax.d.ts +2 -2
  142. package/build/require/type/template-literal/syntax.js +1 -1
  143. package/build/require/type/transform/transform.js +0 -1
  144. package/build/require/type/tuple/tuple.d.ts +1 -2
  145. package/build/require/type/union/union-evaluated.d.ts +6 -10
  146. package/build/require/type/union/union-evaluated.js +7 -2
  147. package/package.json +1 -1
  148. package/build/import/type/modifiers/index.d.mts +0 -1
  149. package/build/import/type/modifiers/index.mjs +0 -1
  150. package/build/import/type/modifiers/modifiers.d.mts +0 -18
  151. package/build/import/type/modifiers/modifiers.mjs +0 -50
  152. package/build/require/type/modifiers/index.d.ts +0 -1
  153. package/build/require/type/modifiers/index.js +0 -18
  154. package/build/require/type/modifiers/modifiers.d.ts +0 -18
  155. package/build/require/type/modifiers/modifiers.js +0 -56
@@ -10,33 +10,33 @@ import { IndexFromMappedKey } from './indexed-from-mapped-key.mjs';
10
10
  // prettier-ignore
11
11
  import { IsArray, IsIntersect, IsObject, IsMappedKey, IsNever, IsSchema, IsTuple, IsUnion } from '../guard/type.mjs';
12
12
  // prettier-ignore
13
- function FromRest(T, K) {
13
+ function FromRest(T, K, Acc = []) {
14
14
  const [L, ...R] = T;
15
15
  return (T.length > 0
16
- ? [FromKey(L, K), ...FromRest(R, K)]
17
- : []);
16
+ ? FromRest(R, K, [...Acc, FromKey(L, K)])
17
+ : Acc);
18
18
  }
19
19
  // prettier-ignore
20
- function FromIntersectRest(T) {
20
+ function FromIntersectRest(T, Acc = []) {
21
21
  const [L, ...R] = T;
22
22
  return (T.length > 0
23
23
  ? IsNever(L)
24
- ? [...FromIntersectRest(R)]
25
- : [L, ...FromIntersectRest(R)]
26
- : []);
24
+ ? FromIntersectRest(R, [...Acc])
25
+ : FromIntersectRest(R, [...Acc, L])
26
+ : Acc);
27
27
  }
28
28
  // prettier-ignore
29
29
  function FromIntersect(T, K) {
30
30
  return (IntersectEvaluated(FromIntersectRest(FromRest(T, K))));
31
31
  }
32
32
  // prettier-ignore
33
- function FromUnionRest(T, S = T) {
33
+ function FromUnionRest(T, Acc = T) {
34
34
  const [L, ...R] = T;
35
35
  return (T.length > 0
36
36
  ? IsNever(L)
37
37
  ? []
38
- : FromUnionRest(R, S)
39
- : S);
38
+ : FromUnionRest(R, Acc)
39
+ : Acc);
40
40
  }
41
41
  // prettier-ignore
42
42
  function FromUnion(T, K) {
@@ -70,11 +70,11 @@ function FromKey(T, K) {
70
70
  Never());
71
71
  }
72
72
  // prettier-ignore
73
- function FromKeys(T, K) {
73
+ function FromKeys(T, K, Acc = []) {
74
74
  const [L, ...R] = K;
75
75
  return (K.length > 0
76
- ? [FromKey(T, L), ...FromKeys(T, R)]
77
- : []);
76
+ ? FromKeys(T, R, [...Acc, FromKey(T, L)])
77
+ : Acc);
78
78
  }
79
79
  // prettier-ignore
80
80
  function FromSchema(T, K) {
@@ -3,7 +3,6 @@ import { CloneType, CloneRest } from '../clone/type.mjs';
3
3
  // ------------------------------------------------------------------
4
4
  // TypeGuard
5
5
  // ------------------------------------------------------------------
6
- // prettier-ignore
7
6
  import { IsObject, IsSchema } from '../guard/type.mjs';
8
7
  // ------------------------------------------------------------------
9
8
  // IntersectCreate
@@ -1,17 +1,13 @@
1
- import type { SchemaOptions, TSchema } from '../schema/index.mjs';
1
+ import type { TSchema } from '../schema/index.mjs';
2
2
  import { type TNever } from '../never/index.mjs';
3
3
  import { type TOptional } from '../optional/index.mjs';
4
4
  import type { TReadonly } from '../readonly/index.mjs';
5
5
  import { TIntersect, IntersectOptions } from './intersect-type.mjs';
6
- type IsIntersectOptional<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<TSchema> ? IsIntersectOptional<R> : false : true);
7
- declare function IsIntersectOptional<T extends TSchema[]>(T: T): IsIntersectOptional<T>;
8
- type RemoveOptionalFromRest<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<infer S extends TSchema> ? [RemoveOptionalFromType<S>, ...RemoveOptionalFromRest<R>] : [L, ...RemoveOptionalFromRest<R>] : []);
9
- declare function RemoveOptionalFromRest<T extends TSchema[]>(T: T): RemoveOptionalFromRest<T>;
10
- type RemoveOptionalFromType<T extends TSchema> = (T extends TReadonly<infer S extends TSchema> ? TReadonly<RemoveOptionalFromType<S>> : T extends TOptional<infer S extends TSchema> ? RemoveOptionalFromType<S> : T);
11
- declare function RemoveOptionalFromType<T extends TSchema>(T: T): RemoveOptionalFromType<T>;
12
- type ResolveIntersect<T extends TSchema[]> = (IsIntersectOptional<T> extends true ? TOptional<TIntersect<RemoveOptionalFromRest<T>>> : TIntersect<RemoveOptionalFromRest<T>>);
13
- declare function ResolveIntersect<T extends TSchema[]>(T: [...T], options: SchemaOptions): ResolveIntersect<T>;
14
- export type IntersectEvaluated<T extends TSchema[]> = (T extends [] ? TNever : T extends [TSchema] ? T[0] : ResolveIntersect<T>);
6
+ type TIsIntersectOptional<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<TSchema> ? TIsIntersectOptional<R> : false : true);
7
+ type TRemoveOptionalFromType<T extends TSchema> = (T extends TReadonly<infer S extends TSchema> ? TReadonly<TRemoveOptionalFromType<S>> : T extends TOptional<infer S extends TSchema> ? TRemoveOptionalFromType<S> : T);
8
+ type TRemoveOptionalFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<infer S extends TSchema> ? TRemoveOptionalFromRest<R, [...Acc, TRemoveOptionalFromType<S>]> : TRemoveOptionalFromRest<R, [...Acc, L]> : Acc);
9
+ type TResolveIntersect<T extends TSchema[]> = (TIsIntersectOptional<T> extends true ? TOptional<TIntersect<TRemoveOptionalFromRest<T>>> : TIntersect<TRemoveOptionalFromRest<T>>);
10
+ export type TIntersectEvaluated<T extends TSchema[]> = (T extends [] ? TNever : T extends [TSchema] ? T[0] : TResolveIntersect<T>);
15
11
  /** `[Json]` Creates an evaluated Intersect type */
16
- export declare function IntersectEvaluated<T extends TSchema[], R = IntersectEvaluated<T>>(T: [...T], options?: IntersectOptions): R;
12
+ export declare function IntersectEvaluated<T extends TSchema[], R = TIntersectEvaluated<T>>(T: [...T], options?: IntersectOptions): R;
17
13
  export {};
@@ -8,25 +8,30 @@ import { IntersectCreate } from './intersect-create.mjs';
8
8
  // TypeGuard
9
9
  // ------------------------------------------------------------------
10
10
  // prettier-ignore
11
- import { IsOptional as IsOptionalType, IsTransform as IsTransformType, } from '../guard/type.mjs';
11
+ import { IsOptional, IsTransform, } from '../guard/type.mjs';
12
12
  // prettier-ignore
13
13
  function IsIntersectOptional(T) {
14
14
  const [L, ...R] = T;
15
15
  return (T.length > 0
16
- ? IsOptionalType(L)
16
+ ? IsOptional(L)
17
17
  ? IsIntersectOptional(R)
18
18
  : false
19
19
  : true);
20
20
  }
21
21
  // prettier-ignore
22
- function RemoveOptionalFromRest(T) {
23
- return (T.map(T => RemoveOptionalFromType(T)));
24
- }
25
- // prettier-ignore
26
22
  function RemoveOptionalFromType(T) {
27
23
  return (Discard(T, [OptionalKind]));
28
24
  }
29
25
  // prettier-ignore
26
+ function RemoveOptionalFromRest(T, Acc = []) {
27
+ const [L, ...R] = T;
28
+ return (T.length > 0
29
+ ? IsOptional(L)
30
+ ? RemoveOptionalFromRest(R, [...Acc, RemoveOptionalFromType(L)])
31
+ : RemoveOptionalFromRest(R, [...Acc, L])
32
+ : Acc);
33
+ }
34
+ // prettier-ignore
30
35
  function ResolveIntersect(T, options) {
31
36
  return (IsIntersectOptional(T)
32
37
  ? Optional(IntersectCreate(RemoveOptionalFromRest(T), options))
@@ -38,7 +43,7 @@ export function IntersectEvaluated(T, options = {}) {
38
43
  return Never(options);
39
44
  if (T.length === 1)
40
45
  return CloneType(T[0], options);
41
- if (T.some((schema) => IsTransformType(schema)))
46
+ if (T.some((schema) => IsTransform(schema)))
42
47
  throw new Error('Cannot intersect transform types');
43
48
  return ResolveIntersect(T, options);
44
49
  }
@@ -1,14 +1,14 @@
1
1
  import type { TSchema, SchemaOptions } from '../schema/index.mjs';
2
2
  import type { Static } from '../static/index.mjs';
3
3
  import { Kind } from '../symbols/index.mjs';
4
- type IntersectStatic<T extends TSchema[], P extends unknown[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? Static<L, P> & IntersectStatic<R, P> : unknown;
4
+ type TIntersectStatic<T extends TSchema[], P extends unknown[], Acc extends unknown = unknown> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TIntersectStatic<R, P, Acc & Static<L, P>> : Acc;
5
5
  export type TUnevaluatedProperties = undefined | TSchema | boolean;
6
6
  export interface IntersectOptions extends SchemaOptions {
7
7
  unevaluatedProperties?: TUnevaluatedProperties;
8
8
  }
9
9
  export interface TIntersect<T extends TSchema[] = TSchema[]> extends TSchema, IntersectOptions {
10
10
  [Kind]: 'Intersect';
11
- static: IntersectStatic<T, this['params']>;
11
+ static: TIntersectStatic<T, this['params']>;
12
12
  type?: 'object';
13
13
  allOf: [...T];
14
14
  }
@@ -4,8 +4,7 @@ import { IntersectCreate } from './intersect-create.mjs';
4
4
  // ------------------------------------------------------------------
5
5
  // TypeGuard
6
6
  // ------------------------------------------------------------------
7
- // prettier-ignore
8
- import { IsTransform, } from '../guard/type.mjs';
7
+ import { IsTransform } from '../guard/type.mjs';
9
8
  /** `[Json]` Creates an evaluated Intersect type */
10
9
  export function Intersect(T, options = {}) {
11
10
  if (T.length === 0)
@@ -1,16 +1,14 @@
1
1
  import type { SchemaOptions } from '../schema/index.mjs';
2
2
  import type { TProperties } from '../object/index.mjs';
3
+ import { Assert } from '../helpers/index.mjs';
3
4
  import { type TMappedResult, type TMappedKey } from '../mapped/index.mjs';
4
5
  import { type TIntrinsic, type IntrinsicMode } from './intrinsic.mjs';
5
6
  import { TLiteral, TLiteralValue } from '../literal/index.mjs';
6
- type MappedIntrinsicPropertyKey<K extends PropertyKey, M extends IntrinsicMode, P extends TLiteralValue = K extends TLiteralValue ? K : never> = {
7
- [_ in K]: TIntrinsic<TLiteral<P>, M>;
7
+ type TMappedIntrinsicPropertyKey<K extends PropertyKey, M extends IntrinsicMode> = {
8
+ [_ in K]: TIntrinsic<TLiteral<Assert<K, TLiteralValue>>, M>;
8
9
  };
9
- declare function MappedIntrinsicPropertyKey<K extends PropertyKey, M extends IntrinsicMode>(K: K, M: M, options: SchemaOptions): MappedIntrinsicPropertyKey<K, M>;
10
- type MappedIntrinsicPropertyKeys<K extends PropertyKey[], M extends IntrinsicMode> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? MappedIntrinsicPropertyKey<L, M> & MappedIntrinsicPropertyKeys<R, M> : {});
11
- declare function MappedIntrinsicPropertyKeys<K extends PropertyKey[], M extends IntrinsicMode>(K: [...K], M: M, options: SchemaOptions): MappedIntrinsicPropertyKeys<K, M>;
12
- type MappedIntrinsicProperties<K extends TMappedKey, M extends IntrinsicMode> = (MappedIntrinsicPropertyKeys<K['keys'], M>);
13
- declare function MappedIntrinsicProperties<K extends TMappedKey, M extends IntrinsicMode>(T: K, M: M, options: SchemaOptions): MappedIntrinsicProperties<K, M>;
14
- export type TIntrinsicFromMappedKey<K extends TMappedKey, M extends IntrinsicMode, P extends TProperties = MappedIntrinsicProperties<K, M>> = (TMappedResult<P>);
15
- export declare function IntrinsicFromMappedKey<K extends TMappedKey, M extends IntrinsicMode, P extends TProperties = MappedIntrinsicProperties<K, M>>(T: K, M: M, options: SchemaOptions): TMappedResult<P>;
10
+ type TMappedIntrinsicPropertyKeys<K extends PropertyKey[], M extends IntrinsicMode, Acc extends TProperties = {}> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TMappedIntrinsicPropertyKeys<R, M, Acc & TMappedIntrinsicPropertyKey<L, M>> : Acc);
11
+ type TMappedIntrinsicProperties<K extends TMappedKey, M extends IntrinsicMode> = (TMappedIntrinsicPropertyKeys<K['keys'], M>);
12
+ export type TIntrinsicFromMappedKey<K extends TMappedKey, M extends IntrinsicMode, P extends TProperties = TMappedIntrinsicProperties<K, M>> = (TMappedResult<P>);
13
+ export declare function IntrinsicFromMappedKey<K extends TMappedKey, M extends IntrinsicMode, P extends TProperties = TMappedIntrinsicProperties<K, M>>(T: K, M: M, options: SchemaOptions): TMappedResult<P>;
16
14
  export {};
@@ -8,11 +8,11 @@ function MappedIntrinsicPropertyKey(K, M, options) {
8
8
  };
9
9
  }
10
10
  // prettier-ignore
11
- function MappedIntrinsicPropertyKeys(K, M, options) {
11
+ function MappedIntrinsicPropertyKeys(K, M, options, Acc = {}) {
12
12
  const [L, ...R] = K;
13
13
  return (K.length > 0
14
- ? { ...MappedIntrinsicPropertyKey(L, M, options), ...MappedIntrinsicPropertyKeys(R, M, options) }
15
- : {});
14
+ ? MappedIntrinsicPropertyKeys(R, M, options, { ...Acc, ...MappedIntrinsicPropertyKey(L, M, options) })
15
+ : Acc);
16
16
  }
17
17
  // prettier-ignore
18
18
  function MappedIntrinsicProperties(T, M, options) {
@@ -1,17 +1,15 @@
1
1
  import type { TSchema, SchemaOptions } from '../schema/index.mjs';
2
2
  import { type TTemplateLiteral, type TTemplateLiteralKind } from '../template-literal/index.mjs';
3
3
  import { type TIntrinsicFromMappedKey } from './intrinsic-from-mapped-key.mjs';
4
- import { type TLiteral, type TLiteralValue } from '../literal/index.mjs';
4
+ import { type TLiteral } from '../literal/index.mjs';
5
5
  import { type TUnion } from '../union/index.mjs';
6
6
  import { type TMappedKey } from '../mapped/index.mjs';
7
7
  export type IntrinsicMode = 'Uppercase' | 'Lowercase' | 'Capitalize' | 'Uncapitalize';
8
- type FromTemplateLiteral<T extends TTemplateLiteralKind[], M extends IntrinsicMode> = M extends IntrinsicMode ? T extends [infer L extends TTemplateLiteralKind, ...infer R extends TTemplateLiteralKind[]] ? [TIntrinsic<L, M>, ...FromTemplateLiteral<R, M>] : T : T;
9
- declare function FromTemplateLiteral<T extends TTemplateLiteralKind[], M extends IntrinsicMode>(schema: TTemplateLiteral, mode: IntrinsicMode, options: SchemaOptions): FromTemplateLiteral<T, M>;
10
- type FromLiteralValue<T, M extends IntrinsicMode> = (T extends string ? M extends 'Uncapitalize' ? Uncapitalize<T> : M extends 'Capitalize' ? Capitalize<T> : M extends 'Uppercase' ? Uppercase<T> : M extends 'Lowercase' ? Lowercase<T> : string : T);
11
- declare function FromLiteralValue(value: TLiteralValue, mode: IntrinsicMode): string;
12
- type FromRest<T extends TSchema[], M extends IntrinsicMode> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [TIntrinsic<L, M>, ...FromRest<R, M>] : [];
13
- declare function FromRest<T extends TSchema[], M extends IntrinsicMode>(T: [...T], mode: M): FromRest<T, M>;
14
- export type TIntrinsic<T extends TSchema, M extends IntrinsicMode> = T extends TMappedKey ? TIntrinsicFromMappedKey<T, M> : T extends TTemplateLiteral<infer S> ? TTemplateLiteral<FromTemplateLiteral<S, M>> : T extends TUnion<infer S> ? TUnion<FromRest<S, M>> : T extends TLiteral<infer S> ? TLiteral<FromLiteralValue<S, M>> : T;
8
+ type TFromTemplateLiteral<T extends TTemplateLiteralKind[], M extends IntrinsicMode> = M extends IntrinsicMode ? T extends [infer L extends TTemplateLiteralKind, ...infer R extends TTemplateLiteralKind[]] ? [TIntrinsic<L, M>, ...TFromTemplateLiteral<R, M>] : T : T;
9
+ type TFromLiteralValue<T, M extends IntrinsicMode> = (T extends string ? M extends 'Uncapitalize' ? Uncapitalize<T> : M extends 'Capitalize' ? Capitalize<T> : M extends 'Uppercase' ? Uppercase<T> : M extends 'Lowercase' ? Lowercase<T> : string : T);
10
+ type FromRest<T extends TSchema[], M extends IntrinsicMode, Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? FromRest<R, M, [...Acc, TIntrinsic<L, M>]> : Acc;
11
+ declare function FromRest<T extends TSchema[], M extends IntrinsicMode>(T: [...T], M: M, Acc?: TSchema[]): FromRest<T, M>;
12
+ export type TIntrinsic<T extends TSchema, M extends IntrinsicMode> = T extends TMappedKey ? TIntrinsicFromMappedKey<T, M> : T extends TTemplateLiteral<infer S> ? TTemplateLiteral<TFromTemplateLiteral<S, M>> : T extends TUnion<infer S> ? TUnion<FromRest<S, M>> : T extends TLiteral<infer S> ? TLiteral<TFromLiteralValue<S, M>> : T;
15
13
  /** Applies an intrinsic string manipulation to the given type. */
16
14
  export declare function Intrinsic<T extends TMappedKey, M extends IntrinsicMode>(schema: T, mode: M, options?: SchemaOptions): TIntrinsicFromMappedKey<T, M>;
17
15
  /** Applies an intrinsic string manipulation to the given type. */
@@ -5,7 +5,6 @@ import { Union } from '../union/index.mjs';
5
5
  // ------------------------------------------------------------------
6
6
  // TypeGuard
7
7
  // ------------------------------------------------------------------
8
- // prettier-ignore
9
8
  import { IsMappedKey, IsTemplateLiteral, IsUnion, IsLiteral } from '../guard/type.mjs';
10
9
  // ------------------------------------------------------------------
11
10
  // Apply
@@ -45,9 +44,12 @@ function FromLiteralValue(value, mode) {
45
44
  mode === 'Lowercase' ? ApplyLowercase(value) :
46
45
  value) : value.toString());
47
46
  }
48
- function FromRest(T, mode) {
47
+ // prettier-ignore
48
+ function FromRest(T, M, Acc = []) {
49
49
  const [L, ...R] = T;
50
- return (T.length > 0 ? [Intrinsic(L, mode), ...FromRest(R, mode)] : []);
50
+ return (T.length > 0
51
+ ? FromRest(R, M, [...Acc, Intrinsic(L, M)])
52
+ : Acc);
51
53
  }
52
54
  /** Applies an intrinsic string manipulation to the given type. */
53
55
  export function Intrinsic(schema, mode, options = {}) {
@@ -2,12 +2,10 @@ import type { SchemaOptions } from '../schema/index.mjs';
2
2
  import type { TProperties } from '../object/index.mjs';
3
3
  import { type TMappedResult } from '../mapped/index.mjs';
4
4
  import { type TKeyOf } from './keyof.mjs';
5
- type FromProperties<K extends TProperties> = ({
5
+ type TFromProperties<K extends TProperties> = ({
6
6
  [K2 in keyof K]: TKeyOf<K[K2]>;
7
7
  });
8
- declare function FromProperties<K extends TProperties>(K: K, options: SchemaOptions): FromProperties<K>;
9
- type FromMappedResult<K extends TMappedResult> = (FromProperties<K['properties']>);
10
- declare function FromMappedResult<K extends TMappedResult>(K: K, options: SchemaOptions): FromMappedResult<K>;
11
- export type TKeyOfFromMappedResult<T extends TMappedResult, P extends TProperties = FromMappedResult<T>> = (TMappedResult<P>);
12
- export declare function KeyOfFromMappedResult<T extends TMappedResult, P extends TProperties = FromMappedResult<T>>(T: T, options: SchemaOptions): TMappedResult<P>;
8
+ type TFromMappedResult<K extends TMappedResult> = (TFromProperties<K['properties']>);
9
+ export type TKeyOfFromMappedResult<T extends TMappedResult, P extends TProperties = TFromMappedResult<T>> = (TMappedResult<P>);
10
+ export declare function KeyOfFromMappedResult<T extends TMappedResult, P extends TProperties = TFromMappedResult<T>>(T: T, options: SchemaOptions): TMappedResult<P>;
13
11
  export {};
@@ -7,24 +7,20 @@ import type { TTuple } from '../tuple/index.mjs';
7
7
  import type { TArray } from '../array/index.mjs';
8
8
  import type { TObject, TProperties } from '../object/index.mjs';
9
9
  import { OperatorUnionMany, OperatorIntersectMany } from '../operators/index.mjs';
10
- type FromRest<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [KeyOfPropertyKeys<L>, ...FromRest<R>] : []);
11
- declare function FromRest<T extends TSchema[]>(T: [...T]): FromRest<T>;
12
- type FromIntersect<T extends TSchema[], C extends PropertyKey[][] = FromRest<T>> = (OperatorUnionMany<C>);
13
- declare function FromIntersect<T extends TSchema[]>(T: [...T], C?: FromRest<T>): FromIntersect<T>;
14
- type FromUnion<T extends TSchema[], C extends PropertyKey[][] = FromRest<T>> = (OperatorIntersectMany<C>);
10
+ type TFromRest<T extends TSchema[], Acc extends PropertyKey[][] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, TKeyOfPropertyKeys<L>]> : Acc);
11
+ type FromIntersect<T extends TSchema[], C extends PropertyKey[][] = TFromRest<T>, R extends PropertyKey[] = OperatorUnionMany<C>> = R;
12
+ declare function FromIntersect<T extends TSchema[]>(T: [...T]): FromIntersect<T>;
13
+ type FromUnion<T extends TSchema[], C extends PropertyKey[][] = TFromRest<T>, R extends PropertyKey[] = OperatorIntersectMany<C>> = R;
15
14
  declare function FromUnion<T extends TSchema[]>(T: [...T]): FromUnion<T>;
16
- type FromTuple<T extends TSchema[], I extends string = ZeroString> = T extends [infer _ extends TSchema, ...infer R extends TSchema[]] ? [I, ...FromTuple<R, Increment<I>>] : [];
17
- declare function FromTuple<T extends TSchema[]>(T: [...T], I?: string): FromTuple<T>;
18
- type FromArray<_ extends TSchema> = ([
15
+ type TFromTuple<T extends TSchema[], I extends string = ZeroString, Acc extends PropertyKey[] = []> = T extends [infer _ extends TSchema, ...infer R extends TSchema[]] ? TFromTuple<R, Increment<I>, [...Acc, I]> : Acc;
16
+ type TFromArray<_ extends TSchema> = ([
19
17
  '[number]'
20
18
  ]);
21
- declare function FromArray<_ extends TSchema>(_: _): FromArray<_>;
22
- type FromProperties<T extends TProperties> = (UnionToTuple<keyof T>);
23
- declare function FromProperties<T extends TProperties>(T: T): FromProperties<T>;
24
- export type KeyOfPropertyKeys<T extends TSchema> = (T extends TRecursive<infer S> ? KeyOfPropertyKeys<S> : T extends TIntersect<infer S> ? FromIntersect<S> : T extends TUnion<infer S> ? FromUnion<S> : T extends TTuple<infer S> ? FromTuple<S> : T extends TArray<infer S> ? FromArray<S> : T extends TObject<infer S> ? FromProperties<S> : [
19
+ type TFromProperties<T extends TProperties> = (UnionToTuple<keyof T>);
20
+ export type TKeyOfPropertyKeys<T extends TSchema> = (T extends TRecursive<infer S> ? TKeyOfPropertyKeys<S> : T extends TIntersect<infer S> ? FromIntersect<S> : T extends TUnion<infer S> ? FromUnion<S> : T extends TTuple<infer S> ? TFromTuple<S> : T extends TArray<infer S> ? TFromArray<S> : T extends TObject<infer S> ? TFromProperties<S> : [
25
21
  ]);
26
22
  /** Returns a tuple of PropertyKeys derived from the given TSchema. */
27
- export declare function KeyOfPropertyKeys<T extends TSchema>(T: T): KeyOfPropertyKeys<T>;
23
+ export declare function KeyOfPropertyKeys<T extends TSchema>(T: T): TKeyOfPropertyKeys<T>;
28
24
  /** Returns a regular expression pattern derived from the given TSchema */
29
25
  export declare function KeyOfPattern(schema: TSchema): string;
30
26
  export {};
@@ -6,27 +6,30 @@ import { OperatorUnionMany, OperatorIntersectMany } from '../operators/index.mjs
6
6
  // prettier-ignore
7
7
  import { IsIntersect, IsUnion, IsTuple, IsArray, IsObject, IsRecord } from '../guard/type.mjs';
8
8
  // prettier-ignore
9
- function FromRest(T) {
9
+ function FromRest(T, Acc = []) {
10
10
  const [L, ...R] = T;
11
11
  return (T.length > 0
12
- ? [KeyOfPropertyKeys(L), ...FromRest(R)]
13
- : []);
12
+ ? FromRest(R, [...Acc, KeyOfPropertyKeys(L)])
13
+ : Acc);
14
14
  }
15
15
  // prettier-ignore
16
- function FromIntersect(T, C = FromRest(T)) {
17
- return OperatorUnionMany(C);
16
+ function FromIntersect(T) {
17
+ const C = FromRest(T);
18
+ const R = OperatorUnionMany(C);
19
+ return R;
18
20
  }
19
21
  // prettier-ignore
20
22
  function FromUnion(T) {
21
23
  const C = FromRest(T);
22
- return OperatorIntersectMany(C);
24
+ const R = OperatorIntersectMany(C);
25
+ return R;
23
26
  }
24
27
  // prettier-ignore
25
- function FromTuple(T, I = '0') {
28
+ function FromTuple(T, I = '0', Acc = []) {
26
29
  const [_, ...R] = T;
27
30
  return (T.length > 0
28
- ? [I, ...FromTuple(R, Increment(I))]
29
- : []);
31
+ ? FromTuple(R, Increment(I), [...Acc, I])
32
+ : Acc);
30
33
  }
31
34
  // prettier-ignore
32
35
  function FromArray(_) {
@@ -1,15 +1,14 @@
1
1
  import type { TSchema } from '../schema/index.mjs';
2
- import type { Ensure } from '../helpers/index.mjs';
2
+ import type { Assert, Ensure } from '../helpers/index.mjs';
3
3
  import type { TMappedResult } from '../mapped/index.mjs';
4
- import { type TLiteral, TLiteralValue } from '../literal/index.mjs';
4
+ import type { SchemaOptions } from '../schema/index.mjs';
5
+ import { type TLiteral, type TLiteralValue } from '../literal/index.mjs';
5
6
  import { type TNumber } from '../number/index.mjs';
6
- import { type SchemaOptions } from '../schema/index.mjs';
7
- import { KeyOfPropertyKeys } from './keyof-property-keys.mjs';
8
- import { UnionEvaluated } from '../union/index.mjs';
7
+ import { type TKeyOfPropertyKeys } from './keyof-property-keys.mjs';
8
+ import { type TUnionEvaluated } from '../union/index.mjs';
9
9
  import { type TKeyOfFromMappedResult } from './keyof-from-mapped-result.mjs';
10
- type FromLiterals<T extends TLiteralValue[]> = (T extends [infer L extends TLiteralValue, ...infer R extends TLiteralValue[]] ? L extends '[number]' ? [TNumber, ...FromLiterals<R>] : [TLiteral<L>, ...FromLiterals<R>] : []);
11
- declare function FromLiterals<T extends TLiteralValue[]>(T: [...T]): FromLiterals<T>;
12
- export type TKeyOf<T extends TSchema> = (Ensure<UnionEvaluated<FromLiterals<KeyOfPropertyKeys<T>>>>);
10
+ type TFromPropertyKeys<T extends PropertyKey[], Acc extends TSchema[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? L extends '[number]' ? TFromPropertyKeys<R, [...Acc, TNumber]> : TFromPropertyKeys<R, [...Acc, TLiteral<Assert<L, TLiteralValue>>]> : Acc);
11
+ export type TKeyOf<T extends TSchema, K extends PropertyKey[] = TKeyOfPropertyKeys<T>, S extends TSchema[] = TFromPropertyKeys<K>, U = TUnionEvaluated<S>> = (Ensure<U>);
13
12
  /** `[Json]` Creates a KeyOf type */
14
13
  export declare function KeyOf<T extends TMappedResult>(T: T, options?: SchemaOptions): TKeyOfFromMappedResult<T>;
15
14
  /** `[Json]` Creates a KeyOf type */
@@ -10,13 +10,13 @@ import { KeyOfFromMappedResult } from './keyof-from-mapped-result.mjs';
10
10
  // prettier-ignore
11
11
  import { IsMappedResult } from '../guard/type.mjs';
12
12
  // prettier-ignore
13
- function FromLiterals(T) {
13
+ function FromPropertyKeys(T, Acc = []) {
14
14
  const [L, ...R] = T;
15
15
  return (T.length > 0
16
16
  ? L === '[number]'
17
- ? [Number(), ...FromLiterals(R)]
18
- : [Literal(L), ...FromLiterals(R)]
19
- : []);
17
+ ? FromPropertyKeys(R, [...Acc, Number()])
18
+ : FromPropertyKeys(R, [...Acc, Literal(L)])
19
+ : Acc);
20
20
  }
21
21
  /** `[Json]` Creates a KeyOf type */
22
22
  export function KeyOf(T, options = {}) {
@@ -24,7 +24,9 @@ export function KeyOf(T, options = {}) {
24
24
  return KeyOfFromMappedResult(T, options);
25
25
  }
26
26
  else {
27
- const K = UnionEvaluated(FromLiterals(KeyOfPropertyKeys(T)));
28
- return CloneType(K, options);
27
+ const K = KeyOfPropertyKeys(T);
28
+ const S = FromPropertyKeys(K);
29
+ const U = UnionEvaluated(S);
30
+ return CloneType(U, options);
29
31
  }
30
32
  }
@@ -16,26 +16,22 @@ import { type TTuple } from '../tuple/index.mjs';
16
16
  import { type TUnion } from '../union/index.mjs';
17
17
  import { type TMappedResult } from './mapped-result.mjs';
18
18
  import type { TMappedKey } from './mapped-key.mjs';
19
- type FromMappedResult<K extends PropertyKey, P extends TProperties> = (K extends keyof P ? FromSchemaType<K, P[K]> : TMappedResult<P>);
20
- declare function FromMappedResult<K extends PropertyKey, P extends TProperties>(K: K, P: P): FromMappedResult<K, P>;
21
- type MappedKeyToMappedResultProperties<K extends PropertyKey, P extends PropertyKey[]> = (P extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? {
19
+ type TFromMappedResult<K extends PropertyKey, P extends TProperties> = (K extends keyof P ? FromSchemaType<K, P[K]> : TMappedResult<P>);
20
+ type TMappedKeyToMappedResultProperties<K extends PropertyKey, P extends PropertyKey[], Acc extends TProperties = {}> = (P extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TMappedKeyToMappedResultProperties<K, R, Acc & {
22
21
  [_ in L]: TLiteral<Assert<L, TLiteralValue>>;
23
- } & MappedKeyToMappedResultProperties<K, R> : {});
24
- declare function MappedKeyToMappedResultProperties<K extends PropertyKey, P extends PropertyKey[]>(K: K, P: [...P]): MappedKeyToMappedResultProperties<K, P>;
25
- type FromMappedKey<K extends PropertyKey, P extends PropertyKey[], R extends TProperties = MappedKeyToMappedResultProperties<K, P>> = (FromMappedResult<K, R>);
26
- declare function FromMappedKey<K extends PropertyKey, P extends PropertyKey[]>(K: K, P: [...P]): FromMappedResult<K, MappedKeyToMappedResultProperties<K, P>>;
27
- type FromRest<K extends PropertyKey, T extends TSchema[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [FromSchemaType<K, L>, ...FromRest<K, R>] : [];
28
- declare function FromRest<K extends PropertyKey, T extends TSchema[]>(K: K, T: [...T]): FromRest<K, T>;
22
+ }> : Acc);
23
+ type TFromMappedKey<K extends PropertyKey, P extends PropertyKey[], R extends TProperties = TMappedKeyToMappedResultProperties<K, P>> = (TFromMappedResult<K, R>);
24
+ type TFromRest<K extends PropertyKey, T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<K, R, [...Acc, FromSchemaType<K, L>]> : Acc);
29
25
  type FromProperties<K extends PropertyKey, T extends TProperties, R extends TProperties = Evaluate<{
30
26
  [K2 in keyof T]: FromSchemaType<K, T[K2]>;
31
27
  }>> = R;
32
28
  declare function FromProperties<K extends PropertyKey, T extends TProperties>(K: K, T: T): FromProperties<K, T>;
33
- type FromSchemaType<K extends PropertyKey, T extends TSchema> = (T extends TReadonly<infer S> ? TReadonly<FromSchemaType<K, S>> : T extends TOptional<infer S> ? TOptional<FromSchemaType<K, S>> : T extends TMappedResult<infer P> ? FromMappedResult<K, P> : T extends TMappedKey<infer P> ? FromMappedKey<K, P> : T extends TConstructor<infer S extends TSchema[], infer R extends TSchema> ? TConstructor<FromRest<K, S>, FromSchemaType<K, R>> : T extends TFunction<infer S extends TSchema[], infer R extends TSchema> ? TFunction<FromRest<K, S>, FromSchemaType<K, R>> : T extends TAsyncIterator<infer S> ? TAsyncIterator<FromSchemaType<K, S>> : T extends TIterator<infer S> ? TIterator<FromSchemaType<K, S>> : T extends TIntersect<infer S> ? TIntersect<FromRest<K, S>> : T extends TUnion<infer S> ? TUnion<FromRest<K, S>> : T extends TTuple<infer S> ? TTuple<FromRest<K, S>> : T extends TObject<infer S> ? TObject<FromProperties<K, S>> : T extends TArray<infer S> ? TArray<FromSchemaType<K, S>> : T extends TPromise<infer S> ? TPromise<FromSchemaType<K, S>> : T);
29
+ type FromSchemaType<K extends PropertyKey, T extends TSchema> = (T extends TReadonly<infer S> ? TReadonly<FromSchemaType<K, S>> : T extends TOptional<infer S> ? TOptional<FromSchemaType<K, S>> : T extends TMappedResult<infer P> ? TFromMappedResult<K, P> : T extends TMappedKey<infer P> ? TFromMappedKey<K, P> : T extends TConstructor<infer S extends TSchema[], infer R extends TSchema> ? TConstructor<TFromRest<K, S>, FromSchemaType<K, R>> : T extends TFunction<infer S extends TSchema[], infer R extends TSchema> ? TFunction<TFromRest<K, S>, FromSchemaType<K, R>> : T extends TAsyncIterator<infer S> ? TAsyncIterator<FromSchemaType<K, S>> : T extends TIterator<infer S> ? TIterator<FromSchemaType<K, S>> : T extends TIntersect<infer S> ? TIntersect<TFromRest<K, S>> : T extends TUnion<infer S> ? TUnion<TFromRest<K, S>> : T extends TTuple<infer S> ? TTuple<TFromRest<K, S>> : T extends TObject<infer S> ? TObject<FromProperties<K, S>> : T extends TArray<infer S> ? TArray<FromSchemaType<K, S>> : T extends TPromise<infer S> ? TPromise<FromSchemaType<K, S>> : T);
34
30
  declare function FromSchemaType<K extends PropertyKey, T extends TSchema>(K: K, T: T): FromSchemaType<K, T>;
35
- type FromMappedFunctionReturnType<K extends PropertyKey[], T extends TSchema> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? {
31
+ type FromMappedFunctionReturnType<K extends PropertyKey[], T extends TSchema, Acc extends TProperties = {}> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? FromMappedFunctionReturnType<R, T, Acc & {
36
32
  [_ in L]: FromSchemaType<L, T>;
37
- } & FromMappedFunctionReturnType<R, T> : {});
38
- declare function FromMappedFunctionReturnType<K extends PropertyKey[], T extends TSchema>(K: [...K], T: T): FromMappedFunctionReturnType<K, T>;
33
+ }> : Acc);
34
+ declare function FromMappedFunctionReturnType<K extends PropertyKey[], T extends TSchema>(K: [...K], T: T, Acc?: TProperties): FromMappedFunctionReturnType<K, T>;
39
35
  export type TMappedFunction<K extends PropertyKey[], I = TMappedKey<K>> = (T: I) => TSchema;
40
36
  export type TMapped<K extends PropertyKey[], F extends TMappedFunction<K>, R extends TProperties = Evaluate<FromMappedFunctionReturnType<K, ReturnType<F>>>> = Ensure<TObject<R>>;
41
37
  /** `[Json]` Creates a Mapped object type */
@@ -30,11 +30,11 @@ function FromMappedResult(K, P) {
30
30
  : MappedResult(P));
31
31
  }
32
32
  // prettier-ignore
33
- function MappedKeyToMappedResultProperties(K, P) {
33
+ function MappedKeyToMappedResultProperties(K, P, Acc = {}) {
34
34
  const [L, ...R] = P;
35
35
  return (P.length > 0
36
- ? { [L]: Literal(L), ...MappedKeyToMappedResultProperties(K, R) }
37
- : {});
36
+ ? MappedKeyToMappedResultProperties(K, R, { ...Acc, [L]: Literal(L) })
37
+ : Acc);
38
38
  }
39
39
  // prettier-ignore
40
40
  function FromMappedKey(K, P) {
@@ -42,11 +42,11 @@ function FromMappedKey(K, P) {
42
42
  return FromMappedResult(K, R);
43
43
  }
44
44
  // prettier-ignore
45
- function FromRest(K, T) {
45
+ function FromRest(K, T, Acc = []) {
46
46
  const [L, ...R] = T;
47
47
  return (T.length > 0
48
- ? [FromSchemaType(K, L), ...FromRest(K, R)]
49
- : []);
48
+ ? FromRest(K, R, [...Acc, FromSchemaType(K, L)])
49
+ : Acc);
50
50
  }
51
51
  // prettier-ignore
52
52
  function FromProperties(K, T) {
@@ -77,11 +77,11 @@ function FromSchemaType(K, T) {
77
77
  T);
78
78
  }
79
79
  // prettier-ignore
80
- function FromMappedFunctionReturnType(K, T) {
80
+ function FromMappedFunctionReturnType(K, T, Acc = {}) {
81
81
  const [L, ...R] = K;
82
82
  return (K.length > 0
83
- ? { [L]: FromSchemaType(L, T), ...FromMappedFunctionReturnType(R, T) }
84
- : {});
83
+ ? FromMappedFunctionReturnType(R, T, { ...Acc, [L]: FromSchemaType(L, T) })
84
+ : Acc);
85
85
  }
86
86
  /** `[Json]` Creates a Mapped object type */
87
87
  export function Mapped(key, map, options = {}) {
@@ -2,14 +2,11 @@ import type { TSchema, SchemaOptions } from '../schema/index.mjs';
2
2
  import type { TProperties } from '../object/index.mjs';
3
3
  import { type TMappedResult, type TMappedKey } from '../mapped/index.mjs';
4
4
  import { type TOmit } from './omit.mjs';
5
- type FromPropertyKey<T extends TSchema, K extends PropertyKey> = {
5
+ type TFromPropertyKey<T extends TSchema, K extends PropertyKey> = {
6
6
  [_ in K]: TOmit<T, [K]>;
7
7
  };
8
- declare function FromPropertyKey<T extends TSchema, K extends PropertyKey>(T: T, K: K, options: SchemaOptions): FromPropertyKey<T, K>;
9
- type FromPropertyKeys<T extends TSchema, K extends PropertyKey[]> = (K extends [infer LK extends PropertyKey, ...infer RK extends PropertyKey[]] ? FromPropertyKey<T, LK> & FromPropertyKeys<T, RK> : {});
10
- declare function FromPropertyKeys<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K], options: SchemaOptions): FromPropertyKeys<T, K>;
11
- type FromMappedKey<T extends TSchema, K extends TMappedKey> = (FromPropertyKeys<T, K['keys']>);
12
- declare function FromMappedKey<T extends TSchema, K extends TMappedKey>(T: T, K: K, options: SchemaOptions): FromMappedKey<T, K>;
13
- export type TOmitFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = FromMappedKey<T, K>> = (TMappedResult<P>);
14
- export declare function OmitFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = FromMappedKey<T, K>>(T: T, K: K, options: SchemaOptions): TMappedResult<P>;
8
+ type TFromPropertyKeys<T extends TSchema, K extends PropertyKey[], Acc extends TProperties = {}> = (K extends [infer LK extends PropertyKey, ...infer RK extends PropertyKey[]] ? TFromPropertyKeys<T, RK, Acc & TFromPropertyKey<T, LK>> : Acc);
9
+ type TFromMappedKey<T extends TSchema, K extends TMappedKey> = (TFromPropertyKeys<T, K['keys']>);
10
+ export type TOmitFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = TFromMappedKey<T, K>> = (TMappedResult<P>);
11
+ export declare function OmitFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = TFromMappedKey<T, K>>(T: T, K: K, options: SchemaOptions): TMappedResult<P>;
15
12
  export {};
@@ -7,11 +7,11 @@ function FromPropertyKey(T, K, options) {
7
7
  };
8
8
  }
9
9
  // prettier-ignore
10
- function FromPropertyKeys(T, K, options) {
10
+ function FromPropertyKeys(T, K, options, Acc = {}) {
11
11
  const [LK, ...RK] = K;
12
12
  return (K.length > 0
13
- ? { ...FromPropertyKey(T, LK, options), ...FromPropertyKeys(T, RK, options) }
14
- : {});
13
+ ? FromPropertyKeys(T, RK, options, { ...Acc, ...FromPropertyKey(T, LK, options) })
14
+ : Acc);
15
15
  }
16
16
  // prettier-ignore
17
17
  function FromMappedKey(T, K, options) {
@@ -7,15 +7,12 @@ import { type TObject, type TProperties } from '../object/index.mjs';
7
7
  import { type TIndexPropertyKeys } from '../indexed/index.mjs';
8
8
  import { TMappedKey } from '../mapped/index.mjs';
9
9
  import { type TOmitFromMappedKey } from './omit-from-mapped-key.mjs';
10
- type FromIntersect<T extends TSchema[], K extends PropertyKey[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [OmitResolve<L, K>, ...FromIntersect<R, K>] : [];
11
- declare function FromIntersect<T extends TSchema[], K extends PropertyKey[]>(T: T, K: K): FromIntersect<T, K>;
12
- type FromUnion<T extends TSchema[], K extends PropertyKey[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [OmitResolve<L, K>, ...FromUnion<R, K>] : [];
13
- declare function FromUnion<T extends TSchema[], K extends PropertyKey[]>(T: T, K: K): FromUnion<T, K>;
14
- type FromProperties<T extends TProperties, K extends PropertyKey[], I extends PropertyKey = TupleToUnion<K>> = Evaluate<Omit<T, I>>;
15
- declare function FromProperties<T extends TProperties, K extends PropertyKey[]>(T: T, K: K): TProperties;
16
- export type OmitResolve<T extends TProperties, K extends PropertyKey[]> = T extends TRecursive<infer S> ? TRecursive<OmitResolve<S, K>> : T extends TIntersect<infer S> ? TIntersect<FromIntersect<S, K>> : T extends TUnion<infer S> ? TUnion<FromUnion<S, K>> : T extends TObject<infer S> ? TObject<FromProperties<S, K>> : TObject<{}>;
17
- export declare function OmitResolve<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): OmitResolve<T, K>;
18
- export type TOmit<T extends TSchema, K extends PropertyKey[]> = OmitResolve<T, K>;
10
+ type TFromIntersect<T extends TSchema[], K extends PropertyKey[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromIntersect<R, K, [...Acc, TOmitResolve<L, K>]> : Acc);
11
+ type TFromUnion<T extends TSchema[], K extends PropertyKey[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromUnion<R, K, [...Acc, TOmitResolve<L, K>]> : Acc);
12
+ type TFromProperties<T extends TProperties, K extends PropertyKey[], I extends PropertyKey = TupleToUnion<K>> = Evaluate<Omit<T, I>>;
13
+ export type TOmitResolve<T extends TProperties, K extends PropertyKey[]> = T extends TRecursive<infer S> ? TRecursive<TOmitResolve<S, K>> : T extends TIntersect<infer S> ? TIntersect<TFromIntersect<S, K>> : T extends TUnion<infer S> ? TUnion<TFromUnion<S, K>> : T extends TObject<infer S> ? TObject<TFromProperties<S, K>> : TObject<{}>;
14
+ export declare function OmitResolve<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): TOmitResolve<T, K>;
15
+ export type TOmit<T extends TSchema, K extends PropertyKey[]> = TOmitResolve<T, K>;
19
16
  /** `[Json]` Constructs a type whose keys are picked from the given type */
20
17
  export declare function Omit<T extends TSchema, K extends TMappedKey>(T: T, K: K): TOmitFromMappedKey<T, K>;
21
18
  /** `[Json]` Constructs a type whose keys are omitted from the given type */
@@ -9,7 +9,6 @@ import { OmitFromMappedKey } from './omit-from-mapped-key.mjs';
9
9
  // ------------------------------------------------------------------
10
10
  // TypeGuard
11
11
  // ------------------------------------------------------------------
12
- // prettier-ignore
13
12
  import { IsMappedKey, IsIntersect, IsUnion, IsObject, IsSchema } from '../guard/type.mjs';
14
13
  // prettier-ignore
15
14
  function FromIntersect(T, K) {