@sinclair/typebox 0.32.0-dev-20 → 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 (208) hide show
  1. package/build/import/compiler/compiler.mjs +62 -62
  2. package/build/import/errors/errors.mjs +62 -62
  3. package/build/import/index.d.mts +6 -6
  4. package/build/import/index.mjs +1 -1
  5. package/build/import/type/awaited/awaited.d.mts +4 -6
  6. package/build/import/type/awaited/awaited.mjs +3 -3
  7. package/build/import/type/composite/composite.d.mts +8 -8
  8. package/build/import/type/const/const.d.mts +4 -7
  9. package/build/import/type/constructor/constructor.d.mts +4 -4
  10. package/build/import/type/deref/deref.d.mts +2 -2
  11. package/build/import/type/deref/deref.mjs +26 -36
  12. package/build/import/type/exclude/exclude-from-mapped-result.d.mts +4 -6
  13. package/build/import/type/exclude/exclude.d.mts +7 -8
  14. package/build/import/type/extends/extends-from-mapped-key.d.mts +5 -8
  15. package/build/import/type/extends/extends-from-mapped-key.mjs +3 -3
  16. package/build/import/type/extends/extends-from-mapped-result.d.mts +4 -6
  17. package/build/import/type/extends/extends.d.mts +2 -3
  18. package/build/import/type/extract/extract-from-mapped-result.d.mts +4 -6
  19. package/build/import/type/extract/extract.d.mts +8 -8
  20. package/build/import/type/function/function.d.mts +1 -1
  21. package/build/import/type/helpers/helpers.d.mts +1 -1
  22. package/build/import/type/index.d.mts +0 -1
  23. package/build/import/type/index.mjs +0 -1
  24. package/build/import/type/indexed/indexed-from-mapped-key.d.mts +5 -8
  25. package/build/import/type/indexed/indexed-from-mapped-key.mjs +3 -6
  26. package/build/import/type/indexed/indexed-property-keys.d.mts +5 -8
  27. package/build/import/type/indexed/indexed-property-keys.mjs +6 -11
  28. package/build/import/type/indexed/indexed.d.mts +13 -23
  29. package/build/import/type/indexed/indexed.mjs +13 -13
  30. package/build/import/type/intersect/intersect-create.mjs +0 -1
  31. package/build/import/type/intersect/intersect-evaluated.d.mts +7 -11
  32. package/build/import/type/intersect/intersect-evaluated.mjs +12 -7
  33. package/build/import/type/intersect/intersect-type.d.mts +2 -2
  34. package/build/import/type/intersect/intersect.mjs +1 -2
  35. package/build/import/type/intrinsic/intrinsic-from-mapped-key.d.mts +7 -9
  36. package/build/import/type/intrinsic/intrinsic-from-mapped-key.mjs +3 -3
  37. package/build/import/type/intrinsic/intrinsic.d.mts +6 -8
  38. package/build/import/type/intrinsic/intrinsic.mjs +8 -6
  39. package/build/import/type/keyof/keyof-from-mapped-result.d.mts +4 -6
  40. package/build/import/type/keyof/keyof-property-keys.d.mts +9 -13
  41. package/build/import/type/keyof/keyof-property-keys.mjs +12 -9
  42. package/build/import/type/keyof/keyof.d.mts +7 -8
  43. package/build/import/type/keyof/keyof.mjs +8 -6
  44. package/build/import/type/mapped/mapped.d.mts +9 -13
  45. package/build/import/type/mapped/mapped.mjs +9 -9
  46. package/build/import/type/omit/omit-from-mapped-key.d.mts +5 -8
  47. package/build/import/type/omit/omit-from-mapped-key.mjs +3 -3
  48. package/build/import/type/omit/omit.d.mts +6 -9
  49. package/build/import/type/omit/omit.mjs +0 -1
  50. package/build/import/type/operators/operators.d.mts +16 -16
  51. package/build/import/type/operators/operators.mjs +21 -25
  52. package/build/import/type/optional/optional-from-mapped-result.d.mts +4 -6
  53. package/build/import/type/optional/optional.d.mts +3 -7
  54. package/build/import/type/partial/partial-from-mapped-result.d.mts +4 -6
  55. package/build/import/type/partial/partial.d.mts +4 -7
  56. package/build/import/type/partial/partial.mjs +6 -7
  57. package/build/import/type/pick/pick-from-mapped-key.d.mts +5 -8
  58. package/build/import/type/pick/pick-from-mapped-key.mjs +3 -3
  59. package/build/import/type/pick/pick.d.mts +4 -4
  60. package/build/import/type/readonly/readonly-from-mapped-result.d.mts +4 -6
  61. package/build/import/type/readonly/readonly.d.mts +3 -7
  62. package/build/import/type/record/record.d.mts +14 -20
  63. package/build/import/type/record/record.mjs +2 -4
  64. package/build/import/type/ref/ref.mjs +3 -0
  65. package/build/import/type/required/required-from-mapped-result.d.mts +4 -6
  66. package/build/import/type/required/required.d.mts +5 -9
  67. package/build/import/type/required/required.mjs +6 -7
  68. package/build/import/type/rest/rest.d.mts +3 -3
  69. package/build/import/type/schema/schema.d.mts +1 -1
  70. package/build/import/type/static/static.d.mts +1 -1
  71. package/build/import/type/symbol/symbol.d.mts +1 -1
  72. package/build/import/type/template-literal/finite.d.mts +7 -5
  73. package/build/import/type/template-literal/finite.mjs +14 -5
  74. package/build/import/type/template-literal/generate.d.mts +14 -9
  75. package/build/import/type/template-literal/generate.mjs +19 -9
  76. package/build/import/type/template-literal/index.d.mts +1 -1
  77. package/build/import/type/template-literal/index.mjs +1 -1
  78. package/build/import/type/template-literal/{parser.mjs → parse.mjs} +7 -2
  79. package/build/import/type/template-literal/syntax.d.mts +3 -3
  80. package/build/import/type/template-literal/syntax.mjs +2 -3
  81. package/build/import/type/template-literal/template-literal.d.mts +2 -2
  82. package/build/import/type/template-literal/template-literal.mjs +1 -1
  83. package/build/import/type/template-literal/union.d.mts +2 -2
  84. package/build/import/type/template-literal/union.mjs +5 -10
  85. package/build/import/type/transform/transform.mjs +0 -1
  86. package/build/import/type/tuple/tuple.d.mts +1 -2
  87. package/build/import/type/type/json.d.mts +2 -2
  88. package/build/import/type/union/union-evaluated.d.mts +6 -10
  89. package/build/import/type/union/union-evaluated.mjs +7 -2
  90. package/build/import/value/cast/cast.mjs +20 -20
  91. package/build/import/value/check/check.mjs +62 -62
  92. package/build/import/value/clean/clean.mjs +16 -16
  93. package/build/import/value/convert/convert.mjs +36 -36
  94. package/build/import/value/create/create.mjs +66 -67
  95. package/build/import/value/default/default.mjs +16 -16
  96. package/build/import/value/transform/decode.mjs +18 -18
  97. package/build/import/value/transform/encode.mjs +18 -18
  98. package/build/import/value/transform/has.mjs +28 -28
  99. package/build/require/compiler/compiler.js +62 -62
  100. package/build/require/errors/errors.js +62 -62
  101. package/build/require/index.d.ts +6 -6
  102. package/build/require/index.js +4 -2
  103. package/build/require/type/awaited/awaited.d.ts +4 -6
  104. package/build/require/type/awaited/awaited.js +3 -3
  105. package/build/require/type/composite/composite.d.ts +8 -8
  106. package/build/require/type/const/const.d.ts +4 -7
  107. package/build/require/type/constructor/constructor.d.ts +4 -4
  108. package/build/require/type/deref/deref.d.ts +2 -2
  109. package/build/require/type/deref/deref.js +25 -35
  110. package/build/require/type/exclude/exclude-from-mapped-result.d.ts +4 -6
  111. package/build/require/type/exclude/exclude.d.ts +7 -8
  112. package/build/require/type/extends/extends-from-mapped-key.d.ts +5 -8
  113. package/build/require/type/extends/extends-from-mapped-key.js +3 -3
  114. package/build/require/type/extends/extends-from-mapped-result.d.ts +4 -6
  115. package/build/require/type/extends/extends.d.ts +2 -3
  116. package/build/require/type/extract/extract-from-mapped-result.d.ts +4 -6
  117. package/build/require/type/extract/extract.d.ts +8 -8
  118. package/build/require/type/function/function.d.ts +1 -1
  119. package/build/require/type/helpers/helpers.d.ts +1 -1
  120. package/build/require/type/index.d.ts +0 -1
  121. package/build/require/type/index.js +0 -1
  122. package/build/require/type/indexed/indexed-from-mapped-key.d.ts +5 -8
  123. package/build/require/type/indexed/indexed-from-mapped-key.js +3 -6
  124. package/build/require/type/indexed/indexed-property-keys.d.ts +5 -8
  125. package/build/require/type/indexed/indexed-property-keys.js +4 -9
  126. package/build/require/type/indexed/indexed.d.ts +13 -23
  127. package/build/require/type/indexed/indexed.js +13 -13
  128. package/build/require/type/intersect/intersect-create.js +0 -1
  129. package/build/require/type/intersect/intersect-evaluated.d.ts +7 -11
  130. package/build/require/type/intersect/intersect-evaluated.js +9 -4
  131. package/build/require/type/intersect/intersect-type.d.ts +2 -2
  132. package/build/require/type/intersect/intersect.js +0 -1
  133. package/build/require/type/intrinsic/intrinsic-from-mapped-key.d.ts +7 -9
  134. package/build/require/type/intrinsic/intrinsic-from-mapped-key.js +3 -3
  135. package/build/require/type/intrinsic/intrinsic.d.ts +6 -8
  136. package/build/require/type/intrinsic/intrinsic.js +7 -5
  137. package/build/require/type/keyof/keyof-from-mapped-result.d.ts +4 -6
  138. package/build/require/type/keyof/keyof-property-keys.d.ts +9 -13
  139. package/build/require/type/keyof/keyof-property-keys.js +12 -9
  140. package/build/require/type/keyof/keyof.d.ts +7 -8
  141. package/build/require/type/keyof/keyof.js +8 -6
  142. package/build/require/type/mapped/mapped.d.ts +9 -13
  143. package/build/require/type/mapped/mapped.js +9 -9
  144. package/build/require/type/omit/omit-from-mapped-key.d.ts +5 -8
  145. package/build/require/type/omit/omit-from-mapped-key.js +3 -3
  146. package/build/require/type/omit/omit.d.ts +6 -9
  147. package/build/require/type/omit/omit.js +0 -1
  148. package/build/require/type/operators/operators.d.ts +16 -16
  149. package/build/require/type/operators/operators.js +21 -25
  150. package/build/require/type/optional/optional-from-mapped-result.d.ts +4 -6
  151. package/build/require/type/optional/optional.d.ts +3 -7
  152. package/build/require/type/partial/partial-from-mapped-result.d.ts +4 -6
  153. package/build/require/type/partial/partial.d.ts +4 -7
  154. package/build/require/type/partial/partial.js +6 -7
  155. package/build/require/type/pick/pick-from-mapped-key.d.ts +5 -8
  156. package/build/require/type/pick/pick-from-mapped-key.js +3 -3
  157. package/build/require/type/pick/pick.d.ts +4 -4
  158. package/build/require/type/readonly/readonly-from-mapped-result.d.ts +4 -6
  159. package/build/require/type/readonly/readonly.d.ts +3 -7
  160. package/build/require/type/record/record.d.ts +14 -20
  161. package/build/require/type/record/record.js +1 -3
  162. package/build/require/type/ref/ref.js +3 -0
  163. package/build/require/type/required/required-from-mapped-result.d.ts +4 -6
  164. package/build/require/type/required/required.d.ts +5 -9
  165. package/build/require/type/required/required.js +6 -7
  166. package/build/require/type/rest/rest.d.ts +3 -3
  167. package/build/require/type/schema/schema.d.ts +1 -1
  168. package/build/require/type/static/static.d.ts +1 -1
  169. package/build/require/type/symbol/symbol.d.ts +1 -1
  170. package/build/require/type/template-literal/finite.d.ts +7 -5
  171. package/build/require/type/template-literal/finite.js +16 -6
  172. package/build/require/type/template-literal/generate.d.ts +14 -9
  173. package/build/require/type/template-literal/generate.js +22 -11
  174. package/build/require/type/template-literal/index.d.ts +1 -1
  175. package/build/require/type/template-literal/index.js +1 -1
  176. package/build/require/type/template-literal/{parser.js → parse.js} +7 -2
  177. package/build/require/type/template-literal/syntax.d.ts +3 -3
  178. package/build/require/type/template-literal/syntax.js +1 -2
  179. package/build/require/type/template-literal/template-literal.d.ts +2 -2
  180. package/build/require/type/template-literal/template-literal.js +1 -1
  181. package/build/require/type/template-literal/union.d.ts +2 -2
  182. package/build/require/type/template-literal/union.js +5 -10
  183. package/build/require/type/transform/transform.js +0 -1
  184. package/build/require/type/tuple/tuple.d.ts +1 -2
  185. package/build/require/type/type/json.d.ts +2 -2
  186. package/build/require/type/union/union-evaluated.d.ts +6 -10
  187. package/build/require/type/union/union-evaluated.js +7 -2
  188. package/build/require/value/cast/cast.js +20 -20
  189. package/build/require/value/check/check.js +62 -62
  190. package/build/require/value/clean/clean.js +16 -16
  191. package/build/require/value/convert/convert.js +36 -36
  192. package/build/require/value/create/create.js +65 -66
  193. package/build/require/value/default/default.js +16 -16
  194. package/build/require/value/transform/decode.js +18 -18
  195. package/build/require/value/transform/encode.js +18 -18
  196. package/build/require/value/transform/has.js +28 -28
  197. package/package.json +1 -1
  198. package/readme.md +47 -47
  199. package/build/import/type/modifiers/index.d.mts +0 -1
  200. package/build/import/type/modifiers/index.mjs +0 -1
  201. package/build/import/type/modifiers/modifiers.d.mts +0 -18
  202. package/build/import/type/modifiers/modifiers.mjs +0 -50
  203. package/build/require/type/modifiers/index.d.ts +0 -1
  204. package/build/require/type/modifiers/index.js +0 -18
  205. package/build/require/type/modifiers/modifiers.d.ts +0 -18
  206. package/build/require/type/modifiers/modifiers.js +0 -56
  207. /package/build/import/type/template-literal/{parser.d.mts → parse.d.mts} +0 -0
  208. /package/build/require/type/template-literal/{parser.d.ts → parse.d.ts} +0 -0
@@ -6,18 +6,17 @@ import { type TUnion } from '../union/index';
6
6
  import { type TNever } from '../never/index';
7
7
  import { type TLiteral } from '../literal/index';
8
8
  import { type Static } from '../static/index';
9
- import { UnionEvaluated } from '../union/index';
9
+ import { type TUnionEvaluated } from '../union/index';
10
10
  import { type TExcludeFromMappedResult } from './exclude-from-mapped-result';
11
- type ExcludeTemplateLiteralResult<T extends string> = UnionEvaluated<AssertRest<UnionToTuple<{
11
+ type TExcludeTemplateLiteralResult<T extends string> = TUnionEvaluated<AssertRest<UnionToTuple<{
12
12
  [K in T]: TLiteral<K>;
13
13
  }[T]>>>;
14
- type ExcludeTemplateLiteral<T extends TTemplateLiteral, U extends TSchema> = (Exclude<Static<T>, Static<U>> extends infer S ? ExcludeTemplateLiteralResult<Assert<S, string>> : never);
15
- type ExcludeArray<T extends TSchema[], U extends TSchema> = AssertRest<UnionToTuple<{
14
+ type TExcludeTemplateLiteral<T extends TTemplateLiteral, U extends TSchema> = (Exclude<Static<T>, Static<U>> extends infer S ? TExcludeTemplateLiteralResult<Assert<S, string>> : never);
15
+ type TExcludeArray<T extends TSchema[], U extends TSchema> = AssertRest<UnionToTuple<{
16
16
  [K in keyof T]: Static<AssertType<T[K]>> extends Static<U> ? never : T[K];
17
- }[number]>> extends infer R extends TSchema[] ? UnionEvaluated<R> : never;
18
- type ExcludeResolve<T extends TSchema, U extends TSchema> = T extends TTemplateLiteral ? ExcludeTemplateLiteral<T, U> : T extends TUnion<infer S> ? ExcludeArray<S, U> : T extends U ? TNever : T;
19
- declare function ExcludeResolve<L extends TSchema, R extends TSchema>(L: L, R: R): ExcludeResolve<L, R>;
20
- export type TExclude<T extends TSchema, U extends TSchema> = ExcludeResolve<T, U>;
17
+ }[number]>> extends infer R extends TSchema[] ? TUnionEvaluated<R> : never;
18
+ type TExcludeResolve<T extends TSchema, U extends TSchema> = T extends TTemplateLiteral ? TExcludeTemplateLiteral<T, U> : T extends TUnion<infer S> ? TExcludeArray<S, U> : T extends U ? TNever : T;
19
+ export type TExclude<T extends TSchema, U extends TSchema> = TExcludeResolve<T, U>;
21
20
  /** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
22
21
  export declare function Exclude<L extends TMappedResult, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExcludeFromMappedResult<L, R>;
23
22
  /** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
@@ -4,14 +4,11 @@ import type { Assert } from '../helpers/index';
4
4
  import { type TMappedResult, type TMappedKey } from '../mapped/index';
5
5
  import { TLiteral, TLiteralValue } from '../literal/index';
6
6
  import { type TExtends } from './extends';
7
- type FromPropertyKey<K extends PropertyKey, U extends TSchema, L extends TSchema, R extends TSchema> = {
7
+ type TFromPropertyKey<K extends PropertyKey, U extends TSchema, L extends TSchema, R extends TSchema> = {
8
8
  [_ in K]: TExtends<TLiteral<Assert<K, TLiteralValue>>, U, L, R>;
9
9
  };
10
- declare function FromPropertyKey<K extends PropertyKey, U extends TSchema, L extends TSchema, R extends TSchema>(K: K, U: U, L: L, R: R, options: SchemaOptions): FromPropertyKey<K, U, L, R>;
11
- type FromPropertyKeys<K extends PropertyKey[], U extends TSchema, L extends TSchema, R extends TSchema> = (K extends [infer LK extends PropertyKey, ...infer RK extends PropertyKey[]] ? FromPropertyKey<LK, U, L, R> & FromPropertyKeys<RK, U, L, R> : {});
12
- declare function FromPropertyKeys<K extends PropertyKey[], U extends TSchema, L extends TSchema, R extends TSchema>(K: [...K], U: U, L: L, R: R, options: SchemaOptions): FromPropertyKeys<K, U, L, R>;
13
- type FromMappedKey<K extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema> = (FromPropertyKeys<K['keys'], U, L, R>);
14
- declare function FromMappedKey<K extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema>(K: K, U: U, L: L, R: R, options: SchemaOptions): FromMappedKey<K, U, L, R>;
15
- export type TExtendsFromMappedKey<T extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = FromMappedKey<T, U, L, R>> = (TMappedResult<P>);
16
- export declare function ExtendsFromMappedKey<T extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = FromMappedKey<T, U, L, R>>(T: T, U: U, L: L, R: R, options: SchemaOptions): TMappedResult<P>;
10
+ type TFromPropertyKeys<K extends PropertyKey[], U extends TSchema, L extends TSchema, R extends TSchema, Acc extends TProperties = {}> = (K extends [infer LK extends PropertyKey, ...infer RK extends PropertyKey[]] ? TFromPropertyKeys<RK, U, L, R, Acc & TFromPropertyKey<LK, U, L, R>> : Acc);
11
+ type TFromMappedKey<K extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema> = (TFromPropertyKeys<K['keys'], U, L, R>);
12
+ export type TExtendsFromMappedKey<T extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = TFromMappedKey<T, U, L, R>> = (TMappedResult<P>);
13
+ export declare function ExtendsFromMappedKey<T extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = TFromMappedKey<T, U, L, R>>(T: T, U: U, L: L, R: R, options: SchemaOptions): TMappedResult<P>;
17
14
  export {};
@@ -12,11 +12,11 @@ function FromPropertyKey(K, U, L, R, options) {
12
12
  };
13
13
  }
14
14
  // prettier-ignore
15
- function FromPropertyKeys(K, U, L, R, options) {
15
+ function FromPropertyKeys(K, U, L, R, options, Acc = {}) {
16
16
  const [LK, ...RK] = K;
17
17
  return (K.length > 0
18
- ? { ...FromPropertyKey(LK, U, L, R, options), ...FromPropertyKeys(RK, U, L, R, options) }
19
- : {});
18
+ ? FromPropertyKeys(RK, U, L, R, options, { ...Acc, ...FromPropertyKey(LK, U, L, R, options) })
19
+ : Acc);
20
20
  }
21
21
  // prettier-ignore
22
22
  function FromMappedKey(K, U, L, R, options) {
@@ -2,12 +2,10 @@ import type { TSchema, SchemaOptions } from '../schema/index';
2
2
  import type { TProperties } from '../object/index';
3
3
  import { type TMappedResult } from '../mapped/index';
4
4
  import { type TExtends } from './extends';
5
- type FromProperties<K extends TProperties, U extends TSchema, L extends TSchema, R extends TSchema> = ({
5
+ type TFromProperties<K extends TProperties, U extends TSchema, L extends TSchema, R extends TSchema> = ({
6
6
  [K2 in keyof K]: TExtends<K[K2], U, L, R>;
7
7
  });
8
- declare function FromProperties<K extends TProperties, U extends TSchema, L extends TSchema, R extends TSchema>(K: K, U: U, L: L, R: R, options: SchemaOptions): FromProperties<K, U, L, R>;
9
- type FromMappedResult<K extends TMappedResult, U extends TSchema, L extends TSchema, R extends TSchema> = (FromProperties<K['properties'], U, L, R>);
10
- declare function FromMappedResult<K extends TMappedResult, U extends TSchema, L extends TSchema, R extends TSchema>(K: K, U: U, L: L, R: R, options: SchemaOptions): FromMappedResult<K, U, L, R>;
11
- export type TExtendsFromMappedResult<T extends TMappedResult, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = FromMappedResult<T, U, L, R>> = (TMappedResult<P>);
12
- export declare function ExtendsFromMappedResult<T extends TMappedResult, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = FromMappedResult<T, U, L, R>>(T: T, U: U, L: L, R: R, options: SchemaOptions): TMappedResult<P>;
8
+ type TFromMappedResult<K extends TMappedResult, U extends TSchema, L extends TSchema, R extends TSchema> = (TFromProperties<K['properties'], U, L, R>);
9
+ export type TExtendsFromMappedResult<T extends TMappedResult, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = TFromMappedResult<T, U, L, R>> = (TMappedResult<P>);
10
+ export declare function ExtendsFromMappedResult<T extends TMappedResult, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = TFromMappedResult<T, U, L, R>>(T: T, U: U, L: L, R: R, options: SchemaOptions): TMappedResult<P>;
13
11
  export {};
@@ -5,9 +5,8 @@ import { TMappedKey, TMappedResult } from '../mapped/index';
5
5
  import { UnionToTuple } from '../helpers/index';
6
6
  import { type TExtendsFromMappedKey } from './extends-from-mapped-key';
7
7
  import { type TExtendsFromMappedResult } from './extends-from-mapped-result';
8
- type ExtendsResolve<L extends TSchema, R extends TSchema, T extends TSchema, U extends TSchema> = ((Static<L> extends Static<R> ? T : U) extends infer O extends TSchema ? UnionToTuple<O> extends [infer X extends TSchema, infer Y extends TSchema] ? TUnion<[X, Y]> : O : never);
9
- declare function ExtendsResolve<L extends TSchema, R extends TSchema, T extends TSchema, U extends TSchema>(left: L, right: R, trueType: T, falseType: U): ExtendsResolve<L, R, T, U>;
10
- export type TExtends<L extends TSchema, R extends TSchema, T extends TSchema, F extends TSchema> = ExtendsResolve<L, R, T, F>;
8
+ type TExtendsResolve<L extends TSchema, R extends TSchema, T extends TSchema, U extends TSchema> = ((Static<L> extends Static<R> ? T : U) extends infer O extends TSchema ? UnionToTuple<O> extends [infer X extends TSchema, infer Y extends TSchema] ? TUnion<[X, Y]> : O : never);
9
+ export type TExtends<L extends TSchema, R extends TSchema, T extends TSchema, F extends TSchema> = TExtendsResolve<L, R, T, F>;
11
10
  /** `[Json]` Creates a Conditional type */
12
11
  export declare function Extends<L extends TMappedResult, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): TExtendsFromMappedResult<L, R, T, F>;
13
12
  /** `[Json]` Creates a Conditional type */
@@ -2,12 +2,10 @@ import type { TSchema, SchemaOptions } from '../schema/index';
2
2
  import type { TProperties } from '../object/index';
3
3
  import { type TMappedResult } from '../mapped/index';
4
4
  import { type TExtract } from './extract';
5
- type FromProperties<K extends TProperties, U extends TSchema> = ({
5
+ type TFromProperties<K extends TProperties, U extends TSchema> = ({
6
6
  [K2 in keyof K]: TExtract<K[K2], U>;
7
7
  });
8
- declare function FromProperties<K extends TProperties, U extends TSchema>(K: K, U: U, options: SchemaOptions): FromProperties<K, U>;
9
- type FromMappedResult<K extends TMappedResult, U extends TSchema> = (FromProperties<K['properties'], U>);
10
- declare function FromMappedResult<K extends TMappedResult, U extends TSchema>(K: K, U: U, options: SchemaOptions): FromMappedResult<K, U>;
11
- export type TExtractFromMappedResult<T extends TMappedResult, U extends TSchema, P extends TProperties = FromMappedResult<T, U>> = (TMappedResult<P>);
12
- export declare function ExtractFromMappedResult<T extends TMappedResult, U extends TSchema, P extends TProperties = FromMappedResult<T, U>>(T: T, U: U, options: SchemaOptions): TMappedResult<P>;
8
+ type TFromMappedResult<K extends TMappedResult, U extends TSchema> = (TFromProperties<K['properties'], U>);
9
+ export type TExtractFromMappedResult<T extends TMappedResult, U extends TSchema, P extends TProperties = TFromMappedResult<T, U>> = (TMappedResult<P>);
10
+ export declare function ExtractFromMappedResult<T extends TMappedResult, U extends TSchema, P extends TProperties = TFromMappedResult<T, U>>(T: T, U: U, options: SchemaOptions): TMappedResult<P>;
13
11
  export {};
@@ -5,18 +5,18 @@ import { type TTemplateLiteral } from '../template-literal/index';
5
5
  import { type TLiteral } from '../literal/index';
6
6
  import { type TUnion } from '../union/index';
7
7
  import { type Static } from '../static/index';
8
- import { UnionEvaluated } from '../union/index';
8
+ import { type TUnionEvaluated } from '../union/index';
9
9
  import { type TExtractFromMappedResult } from './extract-from-mapped-result';
10
- type FromTemplateLiteralResult<T extends string> = UnionEvaluated<AssertRest<UnionToTuple<{
10
+ type TFromTemplateLiteralResult<T extends string> = TUnionEvaluated<AssertRest<UnionToTuple<{
11
11
  [K in T]: TLiteral<K>;
12
12
  }[T]>>>;
13
- type FromTemplateLiteral<T extends TTemplateLiteral, U extends TSchema> = Extract<Static<T>, Static<U>> extends infer S ? FromTemplateLiteralResult<Assert<S, string>> : never;
14
- type FromArray<T extends TSchema[], U extends TSchema> = AssertRest<UnionToTuple<{
13
+ type TFromTemplateLiteral<T extends TTemplateLiteral, U extends TSchema> = Extract<Static<T>, Static<U>> extends infer S ? TFromTemplateLiteralResult<Assert<S, string>> : never;
14
+ type TFromArray<T extends TSchema[], U extends TSchema> = AssertRest<UnionToTuple<{
15
15
  [K in keyof T]: Static<AssertType<T[K]>> extends Static<U> ? T[K] : never;
16
- }[number]>> extends infer R extends TSchema[] ? UnionEvaluated<R> : never;
17
- export type ExtractResolve<T extends TSchema, U extends TSchema> = (T extends TTemplateLiteral ? FromTemplateLiteral<T, U> : T extends TUnion<infer S> ? FromArray<S, U> : T extends U ? T : T);
18
- export declare function ExtractResolve<L extends TSchema, R extends TSchema>(L: L, R: R): ExtractResolve<L, R>;
19
- export type TExtract<T extends TSchema, U extends TSchema> = ExtractResolve<T, U>;
16
+ }[number]>> extends infer R extends TSchema[] ? TUnionEvaluated<R> : never;
17
+ export type TExtractResolve<T extends TSchema, U extends TSchema> = (T extends TTemplateLiteral ? TFromTemplateLiteral<T, U> : T extends TUnion<infer S> ? TFromArray<S, U> : T extends U ? T : T);
18
+ export declare function ExtractResolve<L extends TSchema, R extends TSchema>(L: L, R: R): TExtractResolve<L, R>;
19
+ export type TExtract<T extends TSchema, U extends TSchema> = TExtractResolve<T, U>;
20
20
  /** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
21
21
  export declare function Extract<L extends TMappedResult, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtractFromMappedResult<L, R>;
22
22
  /** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
@@ -3,7 +3,7 @@ import type { Static } from '../static/index';
3
3
  import type { Ensure } from '../helpers/index';
4
4
  import { Kind } from '../symbols/index';
5
5
  type FunctionStaticReturnType<T extends TSchema, P extends unknown[]> = Static<T, P>;
6
- type FunctionStaticParameters<T extends TSchema[], P extends unknown[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [Static<L, P>, ...FunctionStaticParameters<R, P>] : [];
6
+ type FunctionStaticParameters<T extends TSchema[], P extends unknown[], Acc extends unknown[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? FunctionStaticParameters<R, P, [...Acc, Static<L, P>]> : Acc;
7
7
  type FunctionStatic<T extends TSchema[], U extends TSchema, P extends unknown[]> = (Ensure<(...param: FunctionStaticParameters<T, P>) => FunctionStaticReturnType<U, P>>);
8
8
  export interface TFunction<T extends TSchema[] = TSchema[], U extends TSchema = TSchema> extends TSchema {
9
9
  [Kind]: 'Function';
@@ -7,7 +7,7 @@ export type TupleToUnion<T extends any[]> = {
7
7
  }[number];
8
8
  export type UnionToIntersect<U> = (U extends unknown ? (arg: U) => 0 : never) extends (arg: infer I) => 0 ? I : never;
9
9
  export type UnionLast<U> = UnionToIntersect<U extends unknown ? (x: U) => 0 : never> extends (x: infer L) => 0 ? L : never;
10
- export type UnionToTuple<U, L = UnionLast<U>> = [U] extends [never] ? [] : [...UnionToTuple<Exclude<U, L>>, L];
10
+ export type UnionToTuple<U, Acc extends unknown[] = [], R = UnionLast<U>> = [U] extends [never] ? Acc : UnionToTuple<Exclude<U, R>, [Extract<U, R>, ...Acc]>;
11
11
  export type Trim<T> = T extends `${' '}${infer U}` ? Trim<U> : T extends `${infer U}${' '}` ? Trim<U> : T;
12
12
  export type Assert<T, E> = T extends E ? T : never;
13
13
  export type Evaluate<T> = T extends infer O ? {
@@ -28,7 +28,6 @@ export * from './iterator/index';
28
28
  export * from './keyof/index';
29
29
  export * from './literal/index';
30
30
  export * from './mapped/index';
31
- export * from './modifiers/index';
32
31
  export * from './never/index';
33
32
  export * from './not/index';
34
33
  export * from './null/index';
@@ -45,7 +45,6 @@ __exportStar(require("./iterator/index"), exports);
45
45
  __exportStar(require("./keyof/index"), exports);
46
46
  __exportStar(require("./literal/index"), exports);
47
47
  __exportStar(require("./mapped/index"), exports);
48
- __exportStar(require("./modifiers/index"), exports);
49
48
  __exportStar(require("./never/index"), exports);
50
49
  __exportStar(require("./not/index"), exports);
51
50
  __exportStar(require("./null/index"), exports);
@@ -3,14 +3,11 @@ import { type TProperties } from '../object/index';
3
3
  import { type TIndex } from './indexed';
4
4
  import { type TMappedResult, type TMappedKey } from '../mapped/index';
5
5
  import { Evaluate } from '../helpers/index';
6
- type MappedIndexPropertyKey<T extends TSchema, K extends PropertyKey> = {
6
+ type TMappedIndexPropertyKey<T extends TSchema, K extends PropertyKey> = {
7
7
  [_ in K]: TIndex<T, [K]>;
8
8
  };
9
- declare function MappedIndexPropertyKey<T extends TSchema, K extends PropertyKey>(T: T, K: K, options: SchemaOptions): MappedIndexPropertyKey<T, K>;
10
- type MappedIndexPropertyKeys<T extends TSchema, K extends PropertyKey[]> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? MappedIndexPropertyKey<T, L> & MappedIndexPropertyKeys<T, R> : {});
11
- declare function MappedIndexPropertyKeys<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K], options: SchemaOptions): MappedIndexPropertyKeys<T, K>;
12
- type MappedIndexProperties<T extends TSchema, K extends TMappedKey> = Evaluate<MappedIndexPropertyKeys<T, K['keys']>>;
13
- declare function MappedIndexProperties<T extends TSchema, K extends TMappedKey>(T: T, K: K, options: SchemaOptions): MappedIndexProperties<T, K>;
14
- export type TIndexFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = MappedIndexProperties<T, K>> = (TMappedResult<P>);
15
- export declare function IndexFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = MappedIndexProperties<T, K>>(T: T, K: K, options: SchemaOptions): TMappedResult<P>;
9
+ type TMappedIndexPropertyKeys<T extends TSchema, K extends PropertyKey[], Acc extends TProperties = {}> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TMappedIndexPropertyKeys<T, R, Acc & TMappedIndexPropertyKey<T, L>> : Acc);
10
+ type TMappedIndexProperties<T extends TSchema, K extends TMappedKey> = Evaluate<TMappedIndexPropertyKeys<T, K['keys']>>;
11
+ export type TIndexFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = TMappedIndexProperties<T, K>> = (TMappedResult<P>);
12
+ export declare function IndexFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = TMappedIndexProperties<T, K>>(T: T, K: K, options: SchemaOptions): TMappedResult<P>;
16
13
  export {};
@@ -6,17 +6,14 @@ const indexed_1 = require("./indexed");
6
6
  const index_1 = require("../mapped/index");
7
7
  // prettier-ignore
8
8
  function MappedIndexPropertyKey(T, K, options) {
9
- // todo: propogate options into index result. This type looks like it
10
- // could use a clean up, possibly inlining it into indexed.ts to
11
- // bring it inline with other mapping types.
12
9
  return { [K]: (0, indexed_1.Index)(T, [K], options) };
13
10
  }
14
11
  // prettier-ignore
15
- function MappedIndexPropertyKeys(T, K, options) {
12
+ function MappedIndexPropertyKeys(T, K, options, Acc = {}) {
16
13
  const [L, ...R] = K;
17
14
  return (K.length > 0
18
- ? { ...MappedIndexPropertyKey(T, L, options), ...MappedIndexPropertyKeys(T, R, options) } // TS 5.4-dev
19
- : {});
15
+ ? MappedIndexPropertyKeys(T, R, options, { ...Acc, ...MappedIndexPropertyKey(T, L, options) })
16
+ : Acc);
20
17
  }
21
18
  // prettier-ignore
22
19
  function MappedIndexProperties(T, K, options) {
@@ -1,16 +1,13 @@
1
- import { type TTemplateLiteral, TemplateLiteralGenerate, IsTemplateLiteralFinite } from '../template-literal/index';
1
+ import { type TTemplateLiteral, TTemplateLiteralGenerate } from '../template-literal/index';
2
2
  import { type TLiteral, type TLiteralValue } from '../literal/index';
3
3
  import { type TInteger } from '../integer/index';
4
4
  import { type TNumber } from '../number/index';
5
5
  import { type TSchema } from '../schema/index';
6
6
  import { type TUnion } from '../union/index';
7
- type FromTemplateLiteral<T extends TTemplateLiteral, F = IsTemplateLiteralFinite<T>> = (F extends true ? TemplateLiteralGenerate<T> extends infer R extends string[] ? R : [] : []);
8
- declare function FromTemplateLiteral<T extends TTemplateLiteral>(T: T): FromTemplateLiteral<T>;
9
- type FromUnion<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [...TIndexPropertyKeys<L>, ...FromUnion<R>] : []);
10
- declare function FromUnion<T extends TSchema[]>(T: T): FromUnion<T>;
11
- type FromLiteral<T extends TLiteralValue> = (T extends PropertyKey ? [`${T}`] : []);
12
- declare function FromLiteral<T extends TLiteralValue>(T: T): FromLiteral<T>;
13
- export type TIndexPropertyKeys<T extends TSchema> = (T extends TTemplateLiteral ? FromTemplateLiteral<T> : T extends TUnion<infer S> ? FromUnion<S> : T extends TLiteral<infer S> ? FromLiteral<S> : T extends TNumber ? ['[number]'] : T extends TInteger ? ['[number]'] : [
7
+ type TFromTemplateLiteral<T extends TTemplateLiteral, R extends string[] = TTemplateLiteralGenerate<T>> = (R);
8
+ type TFromUnion<T extends TSchema[], Acc extends string[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromUnion<R, [...TIndexPropertyKeys<L>, ...Acc]> : Acc);
9
+ type TFromLiteral<T extends TLiteralValue> = (T extends PropertyKey ? [`${T}`] : []);
10
+ export type TIndexPropertyKeys<T extends TSchema> = (T extends TTemplateLiteral ? TFromTemplateLiteral<T> : T extends TUnion<infer S> ? TFromUnion<S> : T extends TLiteral<infer S> ? TFromLiteral<S> : T extends TNumber ? ['[number]'] : T extends TInteger ? ['[number]'] : [
14
11
  ]);
15
12
  /** Returns a tuple of PropertyKeys derived from the given TSchema */
16
13
  export declare function IndexPropertyKeys<T extends TSchema>(T: T): TIndexPropertyKeys<T>;
@@ -10,14 +10,8 @@ const index_1 = require("../template-literal/index");
10
10
  const type_1 = require("../guard/type");
11
11
  // prettier-ignore
12
12
  function FromTemplateLiteral(T) {
13
- const E = (0, index_1.TemplateLiteralParseExact)(T.pattern);
14
- const F = (0, index_1.IsTemplateLiteralFinite)(E);
15
- const S = (0, index_1.TemplateLiteralToUnion)(T);
16
- return (F === true
17
- ? (0, type_1.IsUnionLiteral)(S)
18
- ? S.anyOf.map(S => S.const.toString())
19
- : []
20
- : []);
13
+ const R = (0, index_1.TemplateLiteralGenerate)(T);
14
+ return R.map(S => S.toString());
21
15
  }
22
16
  // prettier-ignore
23
17
  function FromUnion(T) {
@@ -28,7 +22,8 @@ function FromUnion(T) {
28
22
  }
29
23
  // prettier-ignore
30
24
  function FromLiteral(T) {
31
- return ([T.toString()]);
25
+ return ([T.toString()] // TS 5.4 observes TLiteralValue as not having a toString()
26
+ );
32
27
  }
33
28
  /** Returns a tuple of PropertyKeys derived from the given TSchema */
34
29
  // prettier-ignore
@@ -8,32 +8,22 @@ import { type TMappedKey } from '../mapped/index';
8
8
  import { type TUnion } from '../union/index';
9
9
  import { type TTuple } from '../tuple/index';
10
10
  import { type TArray } from '../array/index';
11
- import { IntersectEvaluated } from '../intersect/index';
12
- import { UnionEvaluated } from '../union/index';
11
+ import { type TIntersectEvaluated } from '../intersect/index';
12
+ import { type TUnionEvaluated } from '../union/index';
13
13
  import { type TIndexPropertyKeys } from './indexed-property-keys';
14
14
  import { type TIndexFromMappedKey } from './indexed-from-mapped-key';
15
- type FromRest<T extends TSchema[], K extends PropertyKey> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [FromKey<L, K>, ...FromRest<R, K>] : []);
16
- declare function FromRest<T extends TSchema[], K extends PropertyKey>(T: [...T], K: K): FromRest<T, K>;
17
- type FromIntersectRest<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TNever ? [...FromIntersectRest<R>] : [L, ...FromIntersectRest<R>] : []);
18
- declare function FromIntersectRest<T extends TSchema[]>(T: [...T]): FromIntersectRest<T>;
19
- type FromIntersect<T extends TSchema[], K extends PropertyKey> = (IntersectEvaluated<FromIntersectRest<FromRest<T, K>>>);
20
- declare function FromIntersect<T extends TSchema[], K extends PropertyKey>(T: [...T], K: K): FromIntersect<T, K>;
21
- type FromUnionRest<T extends TSchema[], S = T> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TNever ? [] : FromUnionRest<R, S> : S);
22
- declare function FromUnionRest<T extends TSchema[]>(T: [...T], S?: [...T]): FromUnionRest<T>;
23
- type FromUnion<T extends TSchema[], K extends PropertyKey> = (UnionEvaluated<FromUnionRest<FromRest<T, K>>>);
24
- declare function FromUnion<T extends TSchema[], K extends PropertyKey>(T: [...T], K: K): FromUnion<T, K>;
25
- type FromTuple<T extends TSchema[], K extends PropertyKey> = (K extends keyof T ? T[K] : K extends '[number]' ? UnionEvaluated<T> : TNever);
26
- declare function FromTuple<T extends TSchema[], K extends PropertyKey>(T: [...T], K: K): FromTuple<T, K>;
27
- type FromArray<T extends TSchema, K extends PropertyKey> = (K extends '[number]' ? T : TNever);
28
- declare function FromArray<T extends TSchema, K extends PropertyKey>(T: T, K: K): FromArray<T, K>;
15
+ type TFromRest<T extends TSchema[], K extends PropertyKey, Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, K, [...Acc, Assert<TFromKey<L, K>, TSchema>]> : Acc);
16
+ type TFromIntersectRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TNever ? TFromIntersectRest<R, [...Acc]> : TFromIntersectRest<R, [...Acc, L]> : Acc);
17
+ type TFromIntersect<T extends TSchema[], K extends PropertyKey> = (TIntersectEvaluated<TFromIntersectRest<TFromRest<T, K>>>);
18
+ type TFromUnionRest<T extends TSchema[], Acc extends TSchema[] = T> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TNever ? [] : TFromUnionRest<R, Acc> : Acc);
19
+ type TFromUnion<T extends TSchema[], K extends PropertyKey> = (TUnionEvaluated<TFromUnionRest<TFromRest<T, K>>>);
20
+ type TFromTuple<T extends TSchema[], K extends PropertyKey> = (K extends keyof T ? T[K] : K extends '[number]' ? TUnionEvaluated<T> : TNever);
21
+ type TFromArray<T extends TSchema, K extends PropertyKey> = (K extends '[number]' ? T : TNever);
29
22
  type AssertPropertyKey<T> = Assert<T, string | number>;
30
- type FromProperty<T extends TProperties, K extends PropertyKey> = (K extends keyof T ? T[K] : `${AssertPropertyKey<K>}` extends `${AssertPropertyKey<keyof T>}` ? T[AssertPropertyKey<K>] : TNever);
31
- declare function FromProperty<T extends TProperties, K extends PropertyKey>(T: T, K: K): FromProperty<T, K>;
32
- type FromKey<T extends TSchema, K extends PropertyKey> = (T extends TRecursive<infer S> ? FromKey<S, K> : T extends TIntersect<infer S> ? FromIntersect<S, K> : T extends TUnion<infer S> ? FromUnion<S, K> : T extends TTuple<infer S> ? FromTuple<S, K> : T extends TArray<infer S> ? FromArray<S, K> : T extends TObject<infer S> ? FromProperty<S, K> : TNever);
33
- declare function FromKey<T extends TSchema, K extends PropertyKey>(T: T, K: K): FromKey<T, K>;
34
- type FromKeys<T extends TSchema, K extends PropertyKey[]> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? [FromKey<T, L>, ...FromKeys<T, R>] : []);
35
- declare function FromKeys<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): FromKeys<T, K>;
36
- type FromSchema<T extends TSchema, K extends PropertyKey[]> = (UnionEvaluated<FromKeys<T, K>>);
23
+ type TFromProperty<T extends TProperties, K extends PropertyKey> = (K extends keyof T ? T[K] : `${AssertPropertyKey<K>}` extends `${AssertPropertyKey<keyof T>}` ? T[AssertPropertyKey<K>] : TNever);
24
+ type TFromKey<T extends TSchema, K extends PropertyKey> = (T extends TRecursive<infer S> ? TFromKey<S, K> : T extends TIntersect<infer S> ? TFromIntersect<S, K> : T extends TUnion<infer S> ? TFromUnion<S, K> : T extends TTuple<infer S> ? TFromTuple<S, K> : T extends TArray<infer S> ? TFromArray<S, K> : T extends TObject<infer S> ? TFromProperty<S, K> : TNever);
25
+ type TFromKeys<T extends TSchema, K extends PropertyKey[], Acc extends TSchema[] = []> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TFromKeys<T, R, [...Acc, Assert<TFromKey<T, L>, TSchema>]> : Acc);
26
+ type FromSchema<T extends TSchema, K extends PropertyKey[]> = (TUnionEvaluated<TFromKeys<T, K>>);
37
27
  declare function FromSchema<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): FromSchema<T, K>;
38
28
  export type TIndex<T extends TSchema, K extends PropertyKey[]> = (FromSchema<T, K>);
39
29
  /** `[Json]` Returns an Indexed property type for the given keys */
@@ -14,33 +14,33 @@ const indexed_from_mapped_key_1 = require("./indexed-from-mapped-key");
14
14
  // prettier-ignore
15
15
  const type_2 = require("../guard/type");
16
16
  // prettier-ignore
17
- function FromRest(T, K) {
17
+ function FromRest(T, K, Acc = []) {
18
18
  const [L, ...R] = T;
19
19
  return (T.length > 0
20
- ? [FromKey(L, K), ...FromRest(R, K)]
21
- : []);
20
+ ? FromRest(R, K, [...Acc, FromKey(L, K)])
21
+ : Acc);
22
22
  }
23
23
  // prettier-ignore
24
- function FromIntersectRest(T) {
24
+ function FromIntersectRest(T, Acc = []) {
25
25
  const [L, ...R] = T;
26
26
  return (T.length > 0
27
27
  ? (0, type_2.IsNever)(L)
28
- ? [...FromIntersectRest(R)]
29
- : [L, ...FromIntersectRest(R)]
30
- : []);
28
+ ? FromIntersectRest(R, [...Acc])
29
+ : FromIntersectRest(R, [...Acc, L])
30
+ : Acc);
31
31
  }
32
32
  // prettier-ignore
33
33
  function FromIntersect(T, K) {
34
34
  return ((0, index_2.IntersectEvaluated)(FromIntersectRest(FromRest(T, K))));
35
35
  }
36
36
  // prettier-ignore
37
- function FromUnionRest(T, S = T) {
37
+ function FromUnionRest(T, Acc = T) {
38
38
  const [L, ...R] = T;
39
39
  return (T.length > 0
40
40
  ? (0, type_2.IsNever)(L)
41
41
  ? []
42
- : FromUnionRest(R, S)
43
- : S);
42
+ : FromUnionRest(R, Acc)
43
+ : Acc);
44
44
  }
45
45
  // prettier-ignore
46
46
  function FromUnion(T, K) {
@@ -74,11 +74,11 @@ function FromKey(T, K) {
74
74
  (0, index_1.Never)());
75
75
  }
76
76
  // prettier-ignore
77
- function FromKeys(T, K) {
77
+ function FromKeys(T, K, Acc = []) {
78
78
  const [L, ...R] = K;
79
79
  return (K.length > 0
80
- ? [FromKey(T, L), ...FromKeys(T, R)]
81
- : []);
80
+ ? FromKeys(T, R, [...Acc, FromKey(T, L)])
81
+ : Acc);
82
82
  }
83
83
  // prettier-ignore
84
84
  function FromSchema(T, K) {
@@ -7,7 +7,6 @@ const type_1 = require("../clone/type");
7
7
  // ------------------------------------------------------------------
8
8
  // TypeGuard
9
9
  // ------------------------------------------------------------------
10
- // prettier-ignore
11
10
  const type_2 = require("../guard/type");
12
11
  // ------------------------------------------------------------------
13
12
  // IntersectCreate
@@ -1,17 +1,13 @@
1
- import type { SchemaOptions, TSchema } from '../schema/index';
1
+ import type { TSchema } from '../schema/index';
2
2
  import { type TNever } from '../never/index';
3
3
  import { type TOptional } from '../optional/index';
4
4
  import type { TReadonly } from '../readonly/index';
5
5
  import { TIntersect, IntersectOptions } from './intersect-type';
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 {};
@@ -23,14 +23,19 @@ function IsIntersectOptional(T) {
23
23
  : true);
24
24
  }
25
25
  // prettier-ignore
26
- function RemoveOptionalFromRest(T) {
27
- return (T.map(T => RemoveOptionalFromType(T)));
28
- }
29
- // prettier-ignore
30
26
  function RemoveOptionalFromType(T) {
31
27
  return ((0, index_2.Discard)(T, [index_1.OptionalKind]));
32
28
  }
33
29
  // prettier-ignore
30
+ function RemoveOptionalFromRest(T, Acc = []) {
31
+ const [L, ...R] = T;
32
+ return (T.length > 0
33
+ ? (0, type_2.IsOptional)(L)
34
+ ? RemoveOptionalFromRest(R, [...Acc, RemoveOptionalFromType(L)])
35
+ : RemoveOptionalFromRest(R, [...Acc, L])
36
+ : Acc);
37
+ }
38
+ // prettier-ignore
34
39
  function ResolveIntersect(T, options) {
35
40
  return (IsIntersectOptional(T)
36
41
  ? (0, index_4.Optional)((0, intersect_create_1.IntersectCreate)(RemoveOptionalFromRest(T), options))
@@ -1,14 +1,14 @@
1
1
  import type { TSchema, SchemaOptions } from '../schema/index';
2
2
  import type { Static } from '../static/index';
3
3
  import { Kind } from '../symbols/index';
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
  }
@@ -8,7 +8,6 @@ const intersect_create_1 = require("./intersect-create");
8
8
  // ------------------------------------------------------------------
9
9
  // TypeGuard
10
10
  // ------------------------------------------------------------------
11
- // prettier-ignore
12
11
  const type_2 = require("../guard/type");
13
12
  /** `[Json]` Creates an evaluated Intersect type */
14
13
  function Intersect(T, options = {}) {
@@ -1,16 +1,14 @@
1
1
  import type { SchemaOptions } from '../schema/index';
2
2
  import type { TProperties } from '../object/index';
3
+ import { Assert } from '../helpers/index';
3
4
  import { type TMappedResult, type TMappedKey } from '../mapped/index';
4
5
  import { type TIntrinsic, type IntrinsicMode } from './intrinsic';
5
6
  import { TLiteral, TLiteralValue } from '../literal/index';
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 {};
@@ -12,11 +12,11 @@ function MappedIntrinsicPropertyKey(K, M, options) {
12
12
  };
13
13
  }
14
14
  // prettier-ignore
15
- function MappedIntrinsicPropertyKeys(K, M, options) {
15
+ function MappedIntrinsicPropertyKeys(K, M, options, Acc = {}) {
16
16
  const [L, ...R] = K;
17
17
  return (K.length > 0
18
- ? { ...MappedIntrinsicPropertyKey(L, M, options), ...MappedIntrinsicPropertyKeys(R, M, options) }
19
- : {});
18
+ ? MappedIntrinsicPropertyKeys(R, M, options, { ...Acc, ...MappedIntrinsicPropertyKey(L, M, options) })
19
+ : Acc);
20
20
  }
21
21
  // prettier-ignore
22
22
  function MappedIntrinsicProperties(T, M, options) {
@@ -1,17 +1,15 @@
1
1
  import type { TSchema, SchemaOptions } from '../schema/index';
2
2
  import { type TTemplateLiteral, type TTemplateLiteralKind } from '../template-literal/index';
3
3
  import { type TIntrinsicFromMappedKey } from './intrinsic-from-mapped-key';
4
- import { type TLiteral, type TLiteralValue } from '../literal/index';
4
+ import { type TLiteral } from '../literal/index';
5
5
  import { type TUnion } from '../union/index';
6
6
  import { type TMappedKey } from '../mapped/index';
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. */