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

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
@@ -11,11 +11,11 @@ function FromPropertyKey(T, K, options) {
11
11
  };
12
12
  }
13
13
  // prettier-ignore
14
- function FromPropertyKeys(T, K, options) {
14
+ function FromPropertyKeys(T, K, options, Acc = {}) {
15
15
  const [LK, ...RK] = K;
16
16
  return (K.length > 0
17
- ? { ...FromPropertyKey(T, LK, options), ...FromPropertyKeys(T, RK, options) }
18
- : {});
17
+ ? FromPropertyKeys(T, RK, options, { ...Acc, ...FromPropertyKey(T, LK, options) })
18
+ : Acc);
19
19
  }
20
20
  // prettier-ignore
21
21
  function FromMappedKey(T, K, options) {
@@ -7,15 +7,12 @@ import { type TObject, type TProperties } from '../object/index';
7
7
  import { type TIndexPropertyKeys } from '../indexed/index';
8
8
  import { TMappedKey } from '../mapped/index';
9
9
  import { type TOmitFromMappedKey } from './omit-from-mapped-key';
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 */
@@ -13,7 +13,6 @@ const omit_from_mapped_key_1 = require("./omit-from-mapped-key");
13
13
  // ------------------------------------------------------------------
14
14
  // TypeGuard
15
15
  // ------------------------------------------------------------------
16
- // prettier-ignore
17
16
  const type_2 = require("../guard/type");
18
17
  // prettier-ignore
19
18
  function FromIntersect(T, K) {
@@ -1,24 +1,24 @@
1
- export type OperatorIncludes<T extends PropertyKey[], S extends PropertyKey> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? S extends L ? true : OperatorIncludes<R, S> : false);
1
+ export type TOperatorIncludes<T extends PropertyKey[], S extends PropertyKey> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? S extends L ? true : TOperatorIncludes<R, S> : false);
2
2
  /** Returns true if element S is in the set of T */
3
- export declare function OperatorIncludes<T extends PropertyKey[], S extends PropertyKey>(T: [...T], S: S): OperatorIncludes<T, S>;
4
- export type OperatorSubset<T extends PropertyKey[], S extends PropertyKey[]> = T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? OperatorIncludes<S, L> extends true ? OperatorSubset<R, S> : false : true;
3
+ export declare function OperatorIncludes<T extends PropertyKey[], S extends PropertyKey>(T: [...T], S: S): TOperatorIncludes<T, S>;
4
+ export type TOperatorSubset<T extends PropertyKey[], S extends PropertyKey[]> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorIncludes<S, L> extends true ? TOperatorSubset<R, S> : false : true);
5
5
  /** Returns true if T is a subset of S */
6
- export declare function OperatorSubset<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): OperatorSubset<T, S>;
7
- export type OperatorDistinct<T extends PropertyKey[], Acc extends PropertyKey[] = []> = T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? OperatorIncludes<Acc, L> extends false ? OperatorDistinct<R, [...Acc, L]> : OperatorDistinct<R, [...Acc]> : Acc;
6
+ export declare function OperatorSubset<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TOperatorSubset<T, S>;
7
+ export type TOperatorDistinct<T extends PropertyKey[], Acc extends PropertyKey[] = []> = T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorIncludes<Acc, L> extends false ? TOperatorDistinct<R, [...Acc, L]> : TOperatorDistinct<R, [...Acc]> : Acc;
8
8
  /** Returns a distinct set of elements */
9
- export declare function OperatorDistinct<T extends PropertyKey[]>(T: [...T], Acc?: PropertyKey[]): OperatorDistinct<T>;
10
- export type OperatorIntersect<T extends PropertyKey[], S extends PropertyKey[]> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? OperatorIncludes<S, L> extends true ? [L, ...OperatorIntersect<R, S>] : [...OperatorIntersect<R, S>] : []);
9
+ export declare function OperatorDistinct<T extends PropertyKey[]>(T: [...T], Acc?: PropertyKey[]): TOperatorDistinct<T>;
10
+ export type TOperatorIntersect<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorIncludes<S, L> extends true ? TOperatorIntersect<R, S, [L, ...Acc]> : TOperatorIntersect<R, S, [...Acc]> : Acc);
11
11
  /** Returns the Intersect of the given sets */
12
- export declare function OperatorIntersect<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): OperatorIntersect<T, S>;
13
- export type OperatorUnion<T extends PropertyKey[], S extends PropertyKey[]> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? OperatorIncludes<S, L> extends true ? [...OperatorUnion<R, S>] : [L, ...OperatorUnion<R, S>] : S);
12
+ export declare function OperatorIntersect<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TOperatorIntersect<T, S>;
13
+ export type TOperatorUnion<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = S> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorUnion<R, S, [...Acc, L]> : Acc);
14
14
  /** Returns the Union of the given sets */
15
- export declare function OperatorUnion<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): OperatorUnion<T, S>;
16
- export type OperatorComplement<T extends PropertyKey[], S extends PropertyKey[]> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? OperatorIncludes<S, L> extends true ? [...OperatorComplement<R, S>] : [L, ...OperatorComplement<R, S>] : []);
15
+ export declare function OperatorUnion<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S], Acc?: PropertyKey[]): TOperatorUnion<T, S>;
16
+ export type OperatorComplement<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorIncludes<S, L> extends true ? OperatorComplement<R, S, [...Acc]> : OperatorComplement<R, S, [L, ...Acc]> : Acc);
17
17
  /** Returns the Complement by omitting elements in T that are in S */
18
- export declare function OperatorComplement<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): OperatorComplement<T, S>;
19
- export type OperatorIntersectMany<T extends PropertyKey[][]> = (T extends [infer L extends PropertyKey[]] ? L : T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? OperatorIntersect<L, OperatorIntersectMany<R>> : []);
18
+ export declare function OperatorComplement<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S], Acc?: PropertyKey[]): OperatorComplement<T, S>;
19
+ export type OperatorIntersectMany<T extends PropertyKey[][], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey[]] ? L : T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? OperatorIntersectMany<R, TOperatorIntersect<Acc, L>> : Acc);
20
20
  /** Returns the Intersect of multiple sets */
21
- export declare function OperatorIntersectMany<T extends PropertyKey[][]>(T: [...T]): OperatorIntersectMany<T>;
22
- export type OperatorUnionMany<T extends PropertyKey[][]> = (T extends [infer L extends PropertyKey[]] ? L : T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? OperatorUnion<L, OperatorUnionMany<R>> : []);
21
+ export declare function OperatorIntersectMany<T extends PropertyKey[][]>(T: [...T], Acc?: PropertyKey[]): OperatorIntersectMany<T>;
22
+ export type OperatorUnionMany<T extends PropertyKey[][], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? OperatorUnionMany<R, TOperatorUnion<Acc, L>> : Acc);
23
23
  /** Returns the Union of multiple sets */
24
- export declare function OperatorUnionMany<T extends PropertyKey[][]>(T: [...T]): OperatorUnionMany<T>;
24
+ export declare function OperatorUnionMany<T extends PropertyKey[][]>(T: [...T], Acc?: PropertyKey[]): OperatorUnionMany<T>;
@@ -14,9 +14,9 @@ function OperatorIncludes(T, S) {
14
14
  }
15
15
  exports.OperatorIncludes = OperatorIncludes;
16
16
  /** Returns true if T is a subset of S */
17
- // prettier-ignore
18
17
  function OperatorSubset(T, S) {
19
18
  const [L, ...R] = T;
19
+ // prettier-ignore
20
20
  return (T.length > 0
21
21
  ? OperatorIncludes(S, L) === true
22
22
  ? OperatorSubset(R, S)
@@ -25,20 +25,19 @@ function OperatorSubset(T, S) {
25
25
  }
26
26
  exports.OperatorSubset = OperatorSubset;
27
27
  /** Returns a distinct set of elements */
28
- // prettier-ignore
29
28
  function OperatorDistinct(T, Acc = []) {
30
29
  const [L, ...R] = T;
31
- return (T.length > 0
32
- ? OperatorIncludes(Acc, L) === false
30
+ // prettier-ignore
31
+ return (T.length > 0 ?
32
+ (OperatorIncludes(Acc, L) === false
33
33
  ? OperatorDistinct(R, [...Acc, L])
34
- : OperatorDistinct(R, [...Acc])
35
- : Acc);
34
+ : OperatorDistinct(R, [...Acc])) : Acc);
36
35
  }
37
36
  exports.OperatorDistinct = OperatorDistinct;
38
37
  /** Returns the Intersect of the given sets */
39
- // prettier-ignore
40
38
  function OperatorIntersect(T, S) {
41
39
  const [L, ...R] = T;
40
+ // prettier-ignore
42
41
  return (T.length > 0
43
42
  ? OperatorIncludes(S, L) === true
44
43
  ? [L, ...OperatorIntersect(R, S)]
@@ -47,30 +46,28 @@ function OperatorIntersect(T, S) {
47
46
  }
48
47
  exports.OperatorIntersect = OperatorIntersect;
49
48
  /** Returns the Union of the given sets */
50
- // prettier-ignore
51
- function OperatorUnion(T, S) {
49
+ function OperatorUnion(T, S, Acc = S) {
52
50
  const [L, ...R] = T;
51
+ // prettier-ignore
53
52
  return (T.length > 0
54
- ? OperatorIncludes(S, L) === true
55
- ? [...OperatorUnion(R, S)]
56
- : [L, ...OperatorUnion(R, S)]
57
- : S);
53
+ ? OperatorUnion(R, S, [...Acc, L])
54
+ : Acc);
58
55
  }
59
56
  exports.OperatorUnion = OperatorUnion;
60
57
  /** Returns the Complement by omitting elements in T that are in S */
61
58
  // prettier-ignore
62
- function OperatorComplement(T, S) {
59
+ function OperatorComplement(T, S, Acc = []) {
63
60
  const [L, ...R] = T;
64
61
  return (T.length > 0
65
62
  ? OperatorIncludes(S, L) === true
66
- ? [...OperatorComplement(R, S)]
67
- : [L, ...OperatorComplement(R, S)]
68
- : []);
63
+ ? OperatorComplement(R, S, [...Acc])
64
+ : OperatorComplement(R, S, [L, ...Acc])
65
+ : Acc);
69
66
  }
70
67
  exports.OperatorComplement = OperatorComplement;
71
68
  /** Returns the Intersect of multiple sets */
72
69
  // prettier-ignore
73
- function OperatorIntersectMany(T) {
70
+ function OperatorIntersectMany(T, Acc = []) {
74
71
  return (T.length === 1
75
72
  ? T[0]
76
73
  : (() => {
@@ -82,12 +79,11 @@ function OperatorIntersectMany(T) {
82
79
  }
83
80
  exports.OperatorIntersectMany = OperatorIntersectMany;
84
81
  /** Returns the Union of multiple sets */
85
- function OperatorUnionMany(T) {
86
- return (T.length === 1
87
- ? T[0]
88
- : (() => {
89
- const [L, ...R] = T;
90
- return T.length > 0 ? OperatorUnion(L, OperatorUnionMany(R)) : [];
91
- })());
82
+ function OperatorUnionMany(T, Acc = []) {
83
+ const [L, ...R] = T;
84
+ // prettier-ignore
85
+ return (T.length > 0
86
+ ? OperatorUnionMany(R, OperatorUnion(Acc, L))
87
+ : Acc);
92
88
  }
93
89
  exports.OperatorUnionMany = OperatorUnionMany;
@@ -1,12 +1,10 @@
1
1
  import type { TProperties } from '../object/index';
2
2
  import { type TMappedResult } from '../mapped/index';
3
3
  import { type TOptionalWithFlag } from './optional';
4
- type FromProperties<K extends TProperties, F extends boolean> = ({
4
+ type TFromProperties<K extends TProperties, F extends boolean> = ({
5
5
  [K2 in keyof K]: TOptionalWithFlag<K[K2], F>;
6
6
  });
7
- declare function FromProperties<K extends TProperties, F extends boolean>(K: K, F: F): FromProperties<K, F>;
8
- type FromMappedResult<K extends TMappedResult, F extends boolean> = (FromProperties<K['properties'], F>);
9
- declare function FromMappedResult<K extends TMappedResult, F extends boolean>(K: K, F: F): FromMappedResult<K, F>;
10
- export type TOptionalFromMappedResult<T extends TMappedResult, F extends boolean, P extends TProperties = FromMappedResult<T, F>> = (TMappedResult<P>);
11
- export declare function OptionalFromMappedResult<T extends TMappedResult, F extends boolean, P extends TProperties = FromMappedResult<T, F>>(T: T, F: F): TMappedResult<P>;
7
+ type TFromMappedResult<K extends TMappedResult, F extends boolean> = (TFromProperties<K['properties'], F>);
8
+ export type TOptionalFromMappedResult<T extends TMappedResult, F extends boolean, P extends TProperties = TFromMappedResult<T, F>> = (TMappedResult<P>);
9
+ export declare function OptionalFromMappedResult<T extends TMappedResult, F extends boolean, P extends TProperties = TFromMappedResult<T, F>>(T: T, F: F): TMappedResult<P>;
12
10
  export {};
@@ -3,13 +3,9 @@ import type { Ensure } from '../helpers/index';
3
3
  import { OptionalKind } from '../symbols/index';
4
4
  import type { TMappedResult } from '../mapped/index';
5
5
  import { type TOptionalFromMappedResult } from './optional-from-mapped-result';
6
- type RemoveOptional<T extends TSchema> = T extends TOptional<infer S> ? S : T;
7
- declare function RemoveOptional<T extends TSchema>(schema: T): Record<PropertyKey, any>;
8
- type AddOptional<T extends TSchema> = T extends TOptional<infer S> ? TOptional<S> : Ensure<TOptional<T>>;
9
- declare function AddOptional<T extends TSchema>(schema: T): T & {
10
- [OptionalKind]: string;
11
- };
12
- export type TOptionalWithFlag<T extends TSchema, F extends boolean> = F extends false ? RemoveOptional<T> : AddOptional<T>;
6
+ type TRemoveOptional<T extends TSchema> = T extends TOptional<infer S> ? S : T;
7
+ type TAddOptional<T extends TSchema> = T extends TOptional<infer S> ? TOptional<S> : Ensure<TOptional<T>>;
8
+ export type TOptionalWithFlag<T extends TSchema, F extends boolean> = F extends false ? TRemoveOptional<T> : TAddOptional<T>;
13
9
  export type TOptional<T extends TSchema> = T & {
14
10
  [OptionalKind]: 'Optional';
15
11
  };
@@ -2,12 +2,10 @@ import type { SchemaOptions } from '../schema/index';
2
2
  import type { TProperties } from '../object/index';
3
3
  import { type TMappedResult } from '../mapped/index';
4
4
  import { type TPartial } from './partial';
5
- type FromProperties<K extends TProperties> = ({
5
+ type TFromProperties<K extends TProperties> = ({
6
6
  [K2 in keyof K]: TPartial<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 TPartialFromMappedResult<T extends TMappedResult, P extends TProperties = FromMappedResult<T>> = (TMappedResult<P>);
12
- export declare function PartialFromMappedResult<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 TPartialFromMappedResult<T extends TMappedResult, P extends TProperties = TFromMappedResult<T>> = (TMappedResult<P>);
10
+ export declare function PartialFromMappedResult<T extends TMappedResult, P extends TProperties = TFromMappedResult<T>>(T: T, options: SchemaOptions): TMappedResult<P>;
13
11
  export {};
@@ -9,15 +9,12 @@ import { type TObject, type TProperties } from '../object/index';
9
9
  import { type TIntersect } from '../intersect/index';
10
10
  import { type TUnion } from '../union/index';
11
11
  import { type TPartialFromMappedResult } from './partial-from-mapped-result';
12
- type FromIntersect<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [PartialResolve<L>, ...FromIntersect<R>] : []);
13
- declare function FromIntersect<T extends TSchema[]>(T: [...T]): FromIntersect<T>;
14
- type FromUnion<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [PartialResolve<L>, ...FromUnion<R>] : []);
15
- declare function FromUnion<T extends TSchema[]>(T: [...T]): FromUnion<T>;
16
- type FromProperties<T extends TProperties> = Evaluate<{
12
+ type TFromIntersect<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromIntersect<R, [...Acc, PartialResolve<L>]> : Acc);
13
+ type TFromUnion<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromUnion<R, [...Acc, PartialResolve<L>]> : Acc);
14
+ type TFromProperties<T extends TProperties> = Evaluate<{
17
15
  [K in keyof T]: T[K] extends (TReadonlyOptional<infer S>) ? TReadonlyOptional<S> : T[K] extends (TReadonly<infer S>) ? TReadonlyOptional<S> : T[K] extends (TOptional<infer S>) ? TOptional<S> : TOptional<T[K]>;
18
16
  }>;
19
- declare function FromProperties<T extends TProperties>(T: T): TProperties;
20
- type PartialResolve<T extends TSchema> = (T extends TRecursive<infer S> ? TRecursive<PartialResolve<S>> : T extends TIntersect<infer S> ? TIntersect<FromIntersect<S>> : T extends TUnion<infer S> ? TUnion<FromUnion<S>> : T extends TObject<infer S> ? TObject<FromProperties<S>> : TObject<{}>);
17
+ type PartialResolve<T extends TSchema> = (T extends TRecursive<infer S> ? TRecursive<PartialResolve<S>> : T extends TIntersect<infer S> ? TIntersect<TFromIntersect<S>> : T extends TUnion<infer S> ? TUnion<TFromUnion<S>> : T extends TObject<infer S> ? TObject<TFromProperties<S>> : TObject<{}>);
21
18
  declare function PartialResolve<T extends TSchema>(T: T): PartialResolve<T>;
22
19
  export type TPartial<T extends TSchema> = PartialResolve<T>;
23
20
  /** `[Json]` Constructs a type where all properties are optional */
@@ -13,21 +13,20 @@ const partial_from_mapped_result_1 = require("./partial-from-mapped-result");
13
13
  // ------------------------------------------------------------------
14
14
  // TypeGuard
15
15
  // ------------------------------------------------------------------
16
- // prettier-ignore
17
16
  const type_2 = require("../guard/type");
18
17
  // prettier-ignore
19
- function FromIntersect(T) {
18
+ function FromIntersect(T, Acc = []) {
20
19
  const [L, ...R] = T;
21
20
  return (T.length > 0
22
- ? [PartialResolve(L), ...FromIntersect(R)]
23
- : []);
21
+ ? FromIntersect(R, [...Acc, PartialResolve(L)])
22
+ : Acc);
24
23
  }
25
24
  // prettier-ignore
26
- function FromUnion(T) {
25
+ function FromUnion(T, Acc = []) {
27
26
  const [L, ...R] = T;
28
27
  return (T.length > 0
29
- ? [PartialResolve(L), ...FromUnion(R)]
30
- : []);
28
+ ? FromUnion(R, [...Acc, PartialResolve(L)])
29
+ : Acc);
31
30
  }
32
31
  // prettier-ignore
33
32
  function FromProperties(T) {
@@ -2,14 +2,11 @@ import type { TSchema, SchemaOptions } from '../schema/index';
2
2
  import type { TProperties } from '../object/index';
3
3
  import { type TMappedResult, type TMappedKey } from '../mapped/index';
4
4
  import { type TPick } from './pick';
5
- type FromPropertyKey<T extends TSchema, K extends PropertyKey> = {
5
+ type TFromPropertyKey<T extends TSchema, K extends PropertyKey> = {
6
6
  [_ in K]: TPick<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 TPickFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = FromMappedKey<T, K>> = (TMappedResult<P>);
14
- export declare function PickFromMappedKey<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 TPickFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = TFromMappedKey<T, K>> = (TMappedResult<P>);
11
+ export declare function PickFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = TFromMappedKey<T, K>>(T: T, K: K, options: SchemaOptions): TMappedResult<P>;
15
12
  export {};
@@ -11,11 +11,11 @@ function FromPropertyKey(T, K, options) {
11
11
  };
12
12
  }
13
13
  // prettier-ignore
14
- function FromPropertyKeys(T, K, options) {
14
+ function FromPropertyKeys(T, K, options, Acc = {}) {
15
15
  const [LK, ...RK] = K;
16
16
  return (K.length > 0
17
- ? { ...FromPropertyKey(T, LK, options), ...FromPropertyKeys(T, RK, options) }
18
- : {});
17
+ ? FromPropertyKeys(T, RK, options, { ...Acc, ...FromPropertyKey(T, LK, options) })
18
+ : Acc);
19
19
  }
20
20
  // prettier-ignore
21
21
  function FromMappedKey(T, K, options) {
@@ -7,10 +7,10 @@ import { type TObject, type TProperties } from '../object/index';
7
7
  import { type TIndexPropertyKeys } from '../indexed/index';
8
8
  import { TMappedKey } from '../mapped/index';
9
9
  import { type TPickFromMappedKey } from './pick-from-mapped-key';
10
- type FromIntersect<T extends TSchema[], K extends PropertyKey[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [PickResolve<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[]] ? [PickResolve<L, K>, ...FromUnion<R, K>] : [];
13
- declare function FromUnion<T extends TSchema[], K extends PropertyKey[]>(T: T, K: K): FromUnion<T, K>;
10
+ type FromIntersect<T extends TSchema[], K extends PropertyKey[], Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? FromIntersect<R, K, [...Acc, PickResolve<L, K>]> : Acc;
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[], Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? FromUnion<R, K, [...Acc, PickResolve<L, K>]> : Acc;
13
+ declare function FromUnion<T extends TSchema[], K extends PropertyKey[]>(T: T, K: K): FromUnion<T, K, []>;
14
14
  type FromProperties<T extends TProperties, K extends PropertyKey[], I extends PropertyKey = TupleToUnion<K>> = Evaluate<Pick<T, I & keyof T>>;
15
15
  declare function FromProperties<T extends TProperties, K extends PropertyKey[]>(T: T, K: K): {};
16
16
  export type PickResolve<T extends TProperties, K extends PropertyKey[]> = T extends TRecursive<infer S> ? TRecursive<PickResolve<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<{}>;
@@ -1,12 +1,10 @@
1
1
  import type { TProperties } from '../object/index';
2
2
  import { type TMappedResult } from '../mapped/index';
3
3
  import { type TReadonlyWithFlag } from './readonly';
4
- type FromProperties<K extends TProperties, F extends boolean> = ({
4
+ type TFromProperties<K extends TProperties, F extends boolean> = ({
5
5
  [K2 in keyof K]: TReadonlyWithFlag<K[K2], F>;
6
6
  });
7
- declare function FromProperties<K extends TProperties, F extends boolean>(K: K, F: F): FromProperties<K, F>;
8
- type FromMappedResult<K extends TMappedResult, F extends boolean> = (FromProperties<K['properties'], F>);
9
- declare function FromMappedResult<K extends TMappedResult, F extends boolean>(K: K, F: F): FromMappedResult<K, F>;
10
- export type TReadonlyFromMappedResult<T extends TMappedResult, F extends boolean, P extends TProperties = FromMappedResult<T, F>> = (TMappedResult<P>);
11
- export declare function ReadonlyFromMappedResult<T extends TMappedResult, F extends boolean, P extends TProperties = FromMappedResult<T, F>>(T: T, F: F): TMappedResult<P>;
7
+ type TFromMappedResult<K extends TMappedResult, F extends boolean> = (TFromProperties<K['properties'], F>);
8
+ export type TReadonlyFromMappedResult<T extends TMappedResult, F extends boolean, P extends TProperties = TFromMappedResult<T, F>> = (TMappedResult<P>);
9
+ export declare function ReadonlyFromMappedResult<T extends TMappedResult, F extends boolean, P extends TProperties = TFromMappedResult<T, F>>(T: T, F: F): TMappedResult<P>;
12
10
  export {};
@@ -3,13 +3,9 @@ import type { Ensure } from '../helpers/index';
3
3
  import { ReadonlyKind } from '../symbols/index';
4
4
  import type { TMappedResult } from '../mapped/index';
5
5
  import { type TReadonlyFromMappedResult } from './readonly-from-mapped-result';
6
- type RemoveReadonly<T extends TSchema> = T extends TReadonly<infer S> ? S : T;
7
- declare function RemoveReadonly<T extends TSchema>(schema: T): Record<PropertyKey, any>;
8
- type AddReadonly<T extends TSchema> = T extends TReadonly<infer S> ? TReadonly<S> : Ensure<TReadonly<T>>;
9
- declare function AddReadonly<T extends TSchema>(schema: T): T & {
10
- [ReadonlyKind]: string;
11
- };
12
- export type TReadonlyWithFlag<T extends TSchema, F extends boolean> = F extends false ? RemoveReadonly<T> : AddReadonly<T>;
6
+ type TRemoveReadonly<T extends TSchema> = T extends TReadonly<infer S> ? S : T;
7
+ type TAddReadonly<T extends TSchema> = T extends TReadonly<infer S> ? TReadonly<S> : Ensure<TReadonly<T>>;
8
+ export type TReadonlyWithFlag<T extends TSchema, F extends boolean> = F extends false ? TRemoveReadonly<T> : TAddReadonly<T>;
13
9
  export type TReadonly<T extends TSchema> = T & {
14
10
  [ReadonlyKind]: 'Readonly';
15
11
  };
@@ -11,34 +11,28 @@ import { type TNumber } from '../number/index';
11
11
  import { type TEnum } from '../enum/index';
12
12
  import { TTemplateLiteral, TIsTemplateLiteralFinite } from '../template-literal/index';
13
13
  import { Kind } from '../symbols/index';
14
- type FromTemplateLiteralKeyInfinite<K extends TTemplateLiteral, T extends TSchema> = Ensure<TRecord<K, T>>;
15
- type FromTemplateLiteralKeyFinite<K extends TTemplateLiteral, T extends TSchema, I extends string = Static<K>> = (Ensure<TObject<Evaluate<{
14
+ type TFromTemplateLiteralKeyInfinite<K extends TTemplateLiteral, T extends TSchema> = Ensure<TRecord<K, T>>;
15
+ type TFromTemplateLiteralKeyFinite<K extends TTemplateLiteral, T extends TSchema, I extends string = Static<K>> = (Ensure<TObject<Evaluate<{
16
16
  [_ in I]: T;
17
17
  }>>>);
18
- type FromTemplateLiteralKey<K extends TTemplateLiteral, T extends TSchema> = TIsTemplateLiteralFinite<K> extends false ? FromTemplateLiteralKeyInfinite<K, T> : FromTemplateLiteralKeyFinite<K, T>;
19
- declare function FromTemplateLiteralKey<K extends TTemplateLiteral, T extends TSchema>(K: K, T: T, options: ObjectOptions): FromTemplateLiteralKey<K, T>;
20
- type FromEnumKey<K extends Record<string, string | number>, T extends TSchema> = Ensure<TObject<{
18
+ type TFromTemplateLiteralKey<K extends TTemplateLiteral, T extends TSchema> = TIsTemplateLiteralFinite<K> extends false ? TFromTemplateLiteralKeyInfinite<K, T> : TFromTemplateLiteralKeyFinite<K, T>;
19
+ type TFromEnumKey<K extends Record<string, string | number>, T extends TSchema> = Ensure<TObject<{
21
20
  [_ in K[keyof K]]: T;
22
21
  }>>;
23
- type FromUnionKeyLiteralString<K extends TLiteral<string>, T extends TSchema> = {
22
+ type TFromUnionKeyLiteralString<K extends TLiteral<string>, T extends TSchema> = {
24
23
  [_ in K['const']]: T;
25
24
  };
26
- type FromUnionKeyLiteralNumber<K extends TLiteral<number>, T extends TSchema> = {
25
+ type TFromUnionKeyLiteralNumber<K extends TLiteral<number>, T extends TSchema> = {
27
26
  [_ in K['const']]: T;
28
27
  };
29
- type FromUnionKeyRest<K extends TSchema[], T extends TSchema> = K extends [infer L extends TSchema, ...infer R extends TSchema[]] ? (L extends TUnion<infer S> ? FromUnionKeyRest<S, T> & FromUnionKeyRest<R, T> : L extends TLiteral<string> ? FromUnionKeyLiteralString<L, T> & FromUnionKeyRest<R, T> : L extends TLiteral<number> ? FromUnionKeyLiteralNumber<L, T> & FromUnionKeyRest<R, T> : {}) : {};
30
- type FromUnionKey<K extends TSchema[], T extends TSchema, P extends TProperties = FromUnionKeyRest<K, T>> = (Ensure<TObject<P>>);
31
- declare function FromUnionKey<K extends TSchema[], T extends TSchema>(K: K, T: T, options: ObjectOptions): FromUnionKey<K, T>;
32
- type FromLiteralKey<K extends TLiteralValue, T extends TSchema> = (Ensure<TObject<{
28
+ type TFromUnionKeyRest<K extends TSchema[], T extends TSchema> = K extends [infer L extends TSchema, ...infer R extends TSchema[]] ? (L extends TUnion<infer S> ? TFromUnionKeyRest<S, T> & TFromUnionKeyRest<R, T> : L extends TLiteral<string> ? TFromUnionKeyLiteralString<L, T> & TFromUnionKeyRest<R, T> : L extends TLiteral<number> ? TFromUnionKeyLiteralNumber<L, T> & TFromUnionKeyRest<R, T> : {}) : {};
29
+ type TFromUnionKey<K extends TSchema[], T extends TSchema, P extends TProperties = TFromUnionKeyRest<K, T>> = (Ensure<TObject<P>>);
30
+ type TFromLiteralKey<K extends TLiteralValue, T extends TSchema> = (Ensure<TObject<{
33
31
  [_ in Assert<K, PropertyKey>]: T;
34
32
  }>>);
35
- declare function FromLiteralKey<K extends TLiteralValue, T extends TSchema>(K: K, T: T, options: ObjectOptions): FromLiteralKey<K, T>;
36
- type FromStringKey<_ extends TString, T extends TSchema> = (Ensure<TRecord<TString, T>>);
37
- declare function FromStringKey<K extends TString, T extends TSchema>(K: K, T: T, options: ObjectOptions): FromStringKey<K, T>;
38
- type FromIntegerKey<_ extends TSchema, T extends TSchema> = (Ensure<TRecord<TNumber, T>>);
39
- declare function FromIntegerKey<K extends TInteger, T extends TSchema>(_: K, T: T, options: ObjectOptions): FromIntegerKey<K, T>;
40
- type FromNumberKey<_ extends TSchema, T extends TSchema> = (Ensure<TRecord<TNumber, T>>);
41
- declare function FromNumberKey<K extends TNumber, T extends TSchema>(_: K, T: T, options: ObjectOptions): FromIntegerKey<K, T>;
33
+ type TFromStringKey<_ extends TString, T extends TSchema> = (Ensure<TRecord<TString, T>>);
34
+ type TFromIntegerKey<_ extends TSchema, T extends TSchema> = (Ensure<TRecord<TNumber, T>>);
35
+ type TFromNumberKey<_ extends TSchema, T extends TSchema> = (Ensure<TRecord<TNumber, T>>);
42
36
  type RecordStatic<K extends TSchema, T extends TSchema, P extends unknown[]> = (Record<Assert<Static<K>, PropertyKey>, Static<T, P>>);
43
37
  export interface TRecord<K extends TSchema = TSchema, T extends TSchema = TSchema> extends TSchema {
44
38
  [Kind]: 'Record';
@@ -49,7 +43,7 @@ export interface TRecord<K extends TSchema = TSchema, T extends TSchema = TSchem
49
43
  };
50
44
  additionalProperties: TAdditionalProperties;
51
45
  }
52
- export type TRecordOrObject<K extends TSchema, T extends TSchema> = K extends TTemplateLiteral ? FromTemplateLiteralKey<K, T> : K extends TEnum<infer S> ? FromEnumKey<S, T> : K extends TUnion<infer S> ? FromUnionKey<S, T> : K extends TLiteral<infer S> ? FromLiteralKey<S, T> : K extends TInteger ? FromIntegerKey<K, T> : K extends TNumber ? FromNumberKey<K, T> : K extends TString ? FromStringKey<K, T> : TNever;
46
+ export type TRecordOrObject<K extends TSchema, T extends TSchema> = K extends TTemplateLiteral ? TFromTemplateLiteralKey<K, T> : K extends TEnum<infer S> ? TFromEnumKey<S, T> : K extends TUnion<infer S> ? TFromUnionKey<S, T> : K extends TLiteral<infer S> ? TFromLiteralKey<S, T> : K extends TInteger ? TFromIntegerKey<K, T> : K extends TNumber ? TFromNumberKey<K, T> : K extends TString ? TFromStringKey<K, T> : TNever;
53
47
  /** `[Json]` Creates a Record type */
54
48
  export declare function Record<K extends TSchema, T extends TSchema>(K: K, T: T, options?: ObjectOptions): TRecordOrObject<K, T>;
55
49
  export {};
@@ -14,7 +14,6 @@ const value_1 = require("../guard/value");
14
14
  // ------------------------------------------------------------------
15
15
  // TypeGuard
16
16
  // ------------------------------------------------------------------
17
- // prettier-ignore
18
17
  const type_2 = require("../guard/type");
19
18
  // ------------------------------------------------------------------
20
19
  // RecordCreateFromPattern
@@ -3,6 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.Ref = void 0;
5
5
  const index_1 = require("../symbols/index");
6
+ // ------------------------------------------------------------------
7
+ // TypeGuard
8
+ // ------------------------------------------------------------------
6
9
  const value_1 = require("../guard/value");
7
10
  /** `[Json]` Creates a Ref type. */
8
11
  function Ref(unresolved, options = {}) {
@@ -2,12 +2,10 @@ import type { SchemaOptions } from '../schema/index';
2
2
  import type { TProperties } from '../object/index';
3
3
  import { type TMappedResult } from '../mapped/index';
4
4
  import { type TRequired } from './required';
5
- type FromProperties<K extends TProperties> = ({
5
+ type TFromProperties<K extends TProperties> = ({
6
6
  [K2 in keyof K]: TRequired<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 TRequiredFromMappedResult<T extends TMappedResult, P extends TProperties = FromMappedResult<T>> = (TMappedResult<P>);
12
- export declare function RequiredFromMappedResult<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 TRequiredFromMappedResult<T extends TMappedResult, P extends TProperties = TFromMappedResult<T>> = (TMappedResult<P>);
10
+ export declare function RequiredFromMappedResult<T extends TMappedResult, P extends TProperties = TFromMappedResult<T>>(T: T, options: SchemaOptions): TMappedResult<P>;
13
11
  export {};
@@ -9,17 +9,13 @@ import { type TIntersect } from '../intersect/index';
9
9
  import { type TUnion } from '../union/index';
10
10
  import { type TObject, type TProperties } from '../object/index';
11
11
  import { type TRequiredFromMappedResult } from './required-from-mapped-result';
12
- type FromIntersect<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [RequiredResolve<L>, ...FromIntersect<R>] : []);
13
- declare function FromIntersect<T extends TSchema[]>(T: [...T]): FromIntersect<T>;
14
- type FromUnion<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [RequiredResolve<L>, ...FromUnion<R>] : []);
15
- declare function FromUnion<T extends TSchema[]>(T: [...T]): FromUnion<T>;
16
- type FromProperties<T extends TProperties> = Evaluate<{
12
+ type TFromIntersect<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromIntersect<R, [...Acc, TRequiredResolve<L>]> : Acc);
13
+ type TFromUnion<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromUnion<R, [...Acc, TRequiredResolve<L>]> : Acc);
14
+ type TFromProperties<T extends TProperties> = Evaluate<{
17
15
  [K in keyof T]: T[K] extends (TReadonlyOptional<infer S>) ? TReadonly<S> : T[K] extends (TReadonly<infer S>) ? TReadonly<S> : T[K] extends (TOptional<infer S>) ? S : T[K];
18
16
  }>;
19
- declare function FromProperties<T extends TProperties>(T: T): TProperties;
20
- type RequiredResolve<T extends TSchema> = (T extends TRecursive<infer S> ? TRecursive<RequiredResolve<S>> : T extends TIntersect<infer S> ? TIntersect<FromIntersect<S>> : T extends TUnion<infer S> ? TUnion<FromUnion<S>> : T extends TObject<infer S> ? TObject<FromProperties<S>> : TObject<{}>);
21
- declare function RequiredResolve<T extends TSchema>(T: T): RequiredResolve<T>;
22
- export type TRequired<T extends TSchema> = RequiredResolve<T>;
17
+ type TRequiredResolve<T extends TSchema> = (T extends TRecursive<infer S> ? TRecursive<TRequiredResolve<S>> : T extends TIntersect<infer S> ? TIntersect<TFromIntersect<S>> : T extends TUnion<infer S> ? TUnion<TFromUnion<S>> : T extends TObject<infer S> ? TObject<TFromProperties<S>> : TObject<{}>);
18
+ export type TRequired<T extends TSchema> = TRequiredResolve<T>;
23
19
  /** `[Json]` Constructs a type where all properties are required */
24
20
  export declare function Required<T extends TMappedResult>(T: T, options?: SchemaOptions): TRequiredFromMappedResult<T>;
25
21
  /** `[Json]` Constructs a type where all properties are required */
@@ -12,21 +12,20 @@ const required_from_mapped_result_1 = require("./required-from-mapped-result");
12
12
  // ------------------------------------------------------------------
13
13
  // TypeGuard
14
14
  // ------------------------------------------------------------------
15
- // prettier-ignore
16
15
  const type_2 = require("../guard/type");
17
16
  // prettier-ignore
18
- function FromIntersect(T) {
17
+ function FromIntersect(T, Acc = []) {
19
18
  const [L, ...R] = T;
20
19
  return (T.length > 0
21
- ? [RequiredResolve(L), ...FromIntersect(R)]
22
- : []);
20
+ ? FromIntersect(R, [...Acc, RequiredResolve(L)])
21
+ : Acc);
23
22
  }
24
23
  // prettier-ignore
25
- function FromUnion(T) {
24
+ function FromUnion(T, Acc = []) {
26
25
  const [L, ...R] = T;
27
26
  return (T.length > 0
28
- ? [RequiredResolve(L), ...FromUnion(R)]
29
- : []);
27
+ ? FromUnion(R, [...Acc, RequiredResolve(L)])
28
+ : Acc);
30
29
  }
31
30
  // prettier-ignore
32
31
  function FromProperties(T) {
@@ -2,9 +2,9 @@ import type { TSchema } from '../schema/index';
2
2
  import type { TIntersect } from '../intersect/index';
3
3
  import type { TUnion } from '../union/index';
4
4
  import type { TTuple } from '../tuple/index';
5
- export type RestResolve<T extends TSchema> = T extends TIntersect<infer S> ? [...S] : T extends TUnion<infer S> ? [...S] : T extends TTuple<infer S> ? [...S] : [
5
+ export type TRestResolve<T extends TSchema> = T extends TIntersect<infer S> ? [...S] : T extends TUnion<infer S> ? [...S] : T extends TTuple<infer S> ? [...S] : [
6
6
  ];
7
- export declare function RestResolve<T extends TSchema>(T: T): RestResolve<T>;
8
- export type TRest<T extends TSchema> = RestResolve<T>;
7
+ export declare function RestResolve<T extends TSchema>(T: T): TRestResolve<T>;
8
+ export type TRest<T extends TSchema> = TRestResolve<T>;
9
9
  /** `[Json]` Extracts interior Rest elements from Tuple, Intersect and Union types */
10
10
  export declare function Rest<T extends TSchema>(T: T): TRest<T>;
@@ -22,7 +22,7 @@ import type { TTransform } from '../transform/index';
22
22
  export type DecodeProperties<T extends TProperties> = {
23
23
  [K in keyof T]: DecodeType<T[K]>;
24
24
  };
25
- export type DecodeRest<T extends TSchema[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [DecodeType<L>, ...DecodeRest<R>] : [];
25
+ export type DecodeRest<T extends TSchema[], Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? DecodeRest<R, [...Acc, DecodeType<L>]> : Acc;
26
26
  export type DecodeType<T extends TSchema> = (T extends TOptional<infer S extends TSchema> ? TOptional<DecodeType<S>> : T extends TReadonly<infer S extends TSchema> ? TReadonly<DecodeType<S>> : T extends TTransform<infer _, infer R> ? TUnsafe<R> : T extends TArray<infer S extends TSchema> ? TArray<DecodeType<S>> : T extends TAsyncIterator<infer S extends TSchema> ? TAsyncIterator<DecodeType<S>> : T extends TConstructor<infer P extends TSchema[], infer R extends TSchema> ? TConstructor<DecodeRest<P>, DecodeType<R>> : T extends TEnum<infer S> ? TEnum<S> : T extends TFunction<infer P extends TSchema[], infer R extends TSchema> ? TFunction<DecodeRest<P>, DecodeType<R>> : T extends TIntersect<infer S extends TSchema[]> ? TIntersect<DecodeRest<S>> : T extends TIterator<infer S extends TSchema> ? TIterator<DecodeType<S>> : T extends TNot<infer S extends TSchema> ? TNot<DecodeType<S>> : T extends TObject<infer S> ? TObject<Evaluate<DecodeProperties<S>>> : T extends TPromise<infer S extends TSchema> ? TPromise<DecodeType<S>> : T extends TRecord<infer K, infer S> ? TRecord<K, DecodeType<S>> : T extends TRecursive<infer S extends TSchema> ? TRecursive<DecodeType<S>> : T extends TRef<infer S extends TSchema> ? TRef<DecodeType<S>> : T extends TTuple<infer S extends TSchema[]> ? TTuple<DecodeRest<S>> : T extends TUnion<infer S extends TSchema[]> ? TUnion<DecodeRest<S>> : T);
27
27
  /** Creates an decoded static type from a TypeBox type */
28
28
  export type StaticDecode<T extends TSchema, P extends unknown[] = []> = Static<DecodeType<T>, P>;