@sinclair/typebox 0.34.0 → 0.34.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/build/cjs/syntax/runtime.d.ts +4 -1
  2. package/build/cjs/syntax/runtime.js +3 -1
  3. package/build/cjs/syntax/static.d.ts +3 -3
  4. package/build/cjs/type/array/array.d.ts +1 -1
  5. package/build/cjs/type/awaited/awaited.d.ts +8 -3
  6. package/build/cjs/type/awaited/awaited.js +20 -20
  7. package/build/cjs/type/computed/computed.d.ts +9 -0
  8. package/build/cjs/type/computed/computed.js +10 -0
  9. package/build/cjs/type/computed/index.d.ts +1 -0
  10. package/build/cjs/type/computed/index.js +18 -0
  11. package/build/cjs/type/guard/kind.d.ts +9 -4
  12. package/build/cjs/type/guard/kind.js +10 -0
  13. package/build/cjs/type/guard/type.d.ts +6 -3
  14. package/build/cjs/type/guard/type.js +6 -0
  15. package/build/cjs/type/indexed/indexed-from-mapped-key.d.ts +6 -6
  16. package/build/cjs/type/indexed/indexed-from-mapped-key.js +10 -10
  17. package/build/cjs/type/indexed/indexed-from-mapped-result.d.ts +5 -5
  18. package/build/cjs/type/indexed/indexed-from-mapped-result.js +11 -10
  19. package/build/cjs/type/indexed/indexed-property-keys.d.ts +6 -6
  20. package/build/cjs/type/indexed/indexed-property-keys.js +14 -14
  21. package/build/cjs/type/indexed/indexed.d.ts +34 -20
  22. package/build/cjs/type/indexed/indexed.js +59 -46
  23. package/build/cjs/type/intersect/intersect-evaluated.d.ts +6 -6
  24. package/build/cjs/type/intersect/intersect-evaluated.js +16 -16
  25. package/build/cjs/type/intersect/intersect.d.ts +2 -2
  26. package/build/cjs/type/intersect/intersect.js +6 -6
  27. package/build/cjs/type/keyof/keyof-from-mapped-result.d.ts +6 -6
  28. package/build/cjs/type/keyof/keyof-from-mapped-result.js +10 -10
  29. package/build/cjs/type/keyof/keyof-property-keys.d.ts +7 -7
  30. package/build/cjs/type/keyof/keyof-property-keys.js +22 -22
  31. package/build/cjs/type/keyof/keyof.d.ts +11 -6
  32. package/build/cjs/type/keyof/keyof.js +22 -13
  33. package/build/cjs/type/module/compute.d.ts +54 -0
  34. package/build/cjs/type/module/compute.js +154 -0
  35. package/build/cjs/type/module/infer.d.ts +43 -0
  36. package/build/cjs/type/module/infer.js +3 -0
  37. package/build/cjs/type/module/module.d.ts +8 -52
  38. package/build/cjs/type/module/module.js +14 -11
  39. package/build/cjs/type/not/not.d.ts +1 -1
  40. package/build/cjs/type/not/not.js +2 -2
  41. package/build/cjs/type/omit/omit-from-mapped-key.d.ts +6 -6
  42. package/build/cjs/type/omit/omit-from-mapped-key.js +10 -12
  43. package/build/cjs/type/omit/omit-from-mapped-result.d.ts +5 -5
  44. package/build/cjs/type/omit/omit-from-mapped-result.js +10 -10
  45. package/build/cjs/type/omit/omit.d.ts +26 -14
  46. package/build/cjs/type/omit/omit.js +46 -35
  47. package/build/cjs/type/partial/partial.d.ts +11 -7
  48. package/build/cjs/type/partial/partial.js +36 -24
  49. package/build/cjs/type/pick/pick-from-mapped-key.d.ts +6 -6
  50. package/build/cjs/type/pick/pick-from-mapped-key.js +10 -10
  51. package/build/cjs/type/pick/pick-from-mapped-result.d.ts +5 -5
  52. package/build/cjs/type/pick/pick-from-mapped-result.js +10 -10
  53. package/build/cjs/type/pick/pick.d.ts +25 -15
  54. package/build/cjs/type/pick/pick.js +47 -36
  55. package/build/cjs/type/record/record.d.ts +4 -2
  56. package/build/cjs/type/record/record.js +31 -28
  57. package/build/cjs/type/required/required.d.ts +12 -8
  58. package/build/cjs/type/required/required.js +37 -25
  59. package/build/cjs/type/tuple/tuple.d.ts +1 -1
  60. package/build/cjs/type/tuple/tuple.js +4 -4
  61. package/build/cjs/type/type/javascript.d.ts +10 -10
  62. package/build/cjs/type/type/javascript.js +6 -6
  63. package/build/cjs/type/type/json.d.ts +41 -51
  64. package/build/cjs/type/type/json.js +40 -40
  65. package/build/cjs/type/union/union-evaluated.d.ts +6 -6
  66. package/build/cjs/type/union/union-evaluated.js +11 -10
  67. package/build/cjs/type/union/union.d.ts +1 -1
  68. package/build/cjs/type/union/union.js +4 -4
  69. package/build/cjs/value/check/check.js +3 -3
  70. package/build/cjs/value/transform/decode.js +7 -7
  71. package/build/cjs/value/transform/encode.js +7 -7
  72. package/build/cjs/value/transform/has.js +18 -18
  73. package/build/esm/syntax/runtime.d.mts +4 -1
  74. package/build/esm/syntax/runtime.mjs +3 -1
  75. package/build/esm/syntax/static.d.mts +3 -3
  76. package/build/esm/type/array/array.d.mts +1 -1
  77. package/build/esm/type/awaited/awaited.d.mts +8 -3
  78. package/build/esm/type/awaited/awaited.mjs +20 -20
  79. package/build/esm/type/computed/computed.d.mts +9 -0
  80. package/build/esm/type/computed/computed.mjs +6 -0
  81. package/build/esm/type/computed/index.d.mts +1 -0
  82. package/build/esm/type/computed/index.mjs +1 -0
  83. package/build/esm/type/guard/kind.d.mts +9 -4
  84. package/build/esm/type/guard/kind.mjs +8 -0
  85. package/build/esm/type/guard/type.d.mts +6 -3
  86. package/build/esm/type/guard/type.mjs +5 -0
  87. package/build/esm/type/indexed/indexed-from-mapped-key.d.mts +6 -6
  88. package/build/esm/type/indexed/indexed-from-mapped-key.mjs +10 -10
  89. package/build/esm/type/indexed/indexed-from-mapped-result.d.mts +5 -5
  90. package/build/esm/type/indexed/indexed-from-mapped-result.mjs +11 -10
  91. package/build/esm/type/indexed/indexed-property-keys.d.mts +6 -6
  92. package/build/esm/type/indexed/indexed-property-keys.mjs +14 -14
  93. package/build/esm/type/indexed/indexed.d.mts +34 -20
  94. package/build/esm/type/indexed/indexed.mjs +55 -42
  95. package/build/esm/type/intersect/intersect-evaluated.d.mts +6 -6
  96. package/build/esm/type/intersect/intersect-evaluated.mjs +16 -16
  97. package/build/esm/type/intersect/intersect.d.mts +2 -2
  98. package/build/esm/type/intersect/intersect.mjs +6 -6
  99. package/build/esm/type/keyof/keyof-from-mapped-result.d.mts +6 -6
  100. package/build/esm/type/keyof/keyof-from-mapped-result.mjs +10 -10
  101. package/build/esm/type/keyof/keyof-property-keys.d.mts +7 -7
  102. package/build/esm/type/keyof/keyof-property-keys.mjs +22 -22
  103. package/build/esm/type/keyof/keyof.d.mts +11 -6
  104. package/build/esm/type/keyof/keyof.mjs +22 -13
  105. package/build/esm/type/module/compute.d.mts +54 -0
  106. package/build/esm/type/module/compute.mjs +148 -0
  107. package/build/esm/type/module/infer.d.mts +43 -0
  108. package/build/esm/type/module/infer.mjs +1 -0
  109. package/build/esm/type/module/module.d.mts +8 -52
  110. package/build/esm/type/module/module.mjs +14 -11
  111. package/build/esm/type/not/not.d.mts +1 -1
  112. package/build/esm/type/not/not.mjs +2 -2
  113. package/build/esm/type/omit/omit-from-mapped-key.d.mts +6 -6
  114. package/build/esm/type/omit/omit-from-mapped-key.mjs +10 -12
  115. package/build/esm/type/omit/omit-from-mapped-result.d.mts +5 -5
  116. package/build/esm/type/omit/omit-from-mapped-result.mjs +10 -10
  117. package/build/esm/type/omit/omit.d.mts +26 -14
  118. package/build/esm/type/omit/omit.mjs +43 -32
  119. package/build/esm/type/partial/partial.d.mts +11 -7
  120. package/build/esm/type/partial/partial.mjs +29 -17
  121. package/build/esm/type/pick/pick-from-mapped-key.d.mts +6 -6
  122. package/build/esm/type/pick/pick-from-mapped-key.mjs +10 -10
  123. package/build/esm/type/pick/pick-from-mapped-result.d.mts +5 -5
  124. package/build/esm/type/pick/pick-from-mapped-result.mjs +10 -10
  125. package/build/esm/type/pick/pick.d.mts +25 -15
  126. package/build/esm/type/pick/pick.mjs +43 -32
  127. package/build/esm/type/record/record.d.mts +4 -2
  128. package/build/esm/type/record/record.mjs +15 -12
  129. package/build/esm/type/required/required.d.mts +12 -8
  130. package/build/esm/type/required/required.mjs +33 -21
  131. package/build/esm/type/tuple/tuple.d.mts +1 -1
  132. package/build/esm/type/tuple/tuple.mjs +4 -4
  133. package/build/esm/type/type/javascript.d.mts +10 -10
  134. package/build/esm/type/type/javascript.mjs +6 -6
  135. package/build/esm/type/type/json.d.mts +41 -51
  136. package/build/esm/type/type/json.mjs +40 -40
  137. package/build/esm/type/union/union-evaluated.d.mts +6 -6
  138. package/build/esm/type/union/union-evaluated.mjs +11 -10
  139. package/build/esm/type/union/union.d.mts +1 -1
  140. package/build/esm/type/union/union.mjs +4 -4
  141. package/build/esm/value/check/check.mjs +2 -2
  142. package/build/esm/value/transform/decode.mjs +2 -2
  143. package/build/esm/value/transform/encode.mjs +2 -2
  144. package/build/esm/value/transform/has.mjs +2 -2
  145. package/package.json +1 -1
  146. package/readme.md +30 -19
@@ -3,50 +3,62 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.Required = Required;
5
5
  const type_1 = require("../create/type");
6
- const index_1 = require("../intersect/index");
7
- const index_2 = require("../union/index");
8
- const index_3 = require("../object/index");
9
- const index_4 = require("../symbols/index");
10
- const index_5 = require("../discard/index");
6
+ const index_1 = require("../computed/index");
7
+ const index_2 = require("../object/index");
8
+ const index_3 = require("../intersect/index");
9
+ const index_4 = require("../union/index");
10
+ const index_5 = require("../ref/index");
11
+ const index_6 = require("../symbols/index");
12
+ const index_7 = require("../discard/index");
11
13
  const required_from_mapped_result_1 = require("./required-from-mapped-result");
12
14
  // ------------------------------------------------------------------
13
15
  // TypeGuard
14
16
  // ------------------------------------------------------------------
15
17
  const kind_1 = require("../guard/kind");
16
18
  // prettier-ignore
17
- function FromRest(T) {
18
- return T.map(L => RequiredResolve(L));
19
+ function FromComputed(target, parameters) {
20
+ return (0, index_1.Computed)('Required', [(0, index_1.Computed)(target, parameters)]);
19
21
  }
20
22
  // prettier-ignore
21
- function FromProperties(T) {
22
- const Acc = {};
23
- for (const K of globalThis.Object.getOwnPropertyNames(T))
24
- Acc[K] = (0, index_5.Discard)(T[K], [index_4.OptionalKind]);
25
- return Acc;
23
+ function FromRef($ref) {
24
+ return (0, index_1.Computed)('Required', [(0, index_5.Ref)($ref)]);
26
25
  }
27
26
  // prettier-ignore
28
- function FromObject(T) {
29
- const options = (0, index_5.Discard)(T, [index_4.TransformKind, '$id', 'required', 'properties']);
30
- const properties = FromProperties(T['properties']);
31
- return (0, index_3.Object)(properties, options);
27
+ function FromProperties(properties) {
28
+ const requiredProperties = {};
29
+ for (const K of globalThis.Object.getOwnPropertyNames(properties))
30
+ requiredProperties[K] = (0, index_7.Discard)(properties[K], [index_6.OptionalKind]);
31
+ return requiredProperties;
32
+ }
33
+ // prettier-ignore
34
+ function FromObject(type) {
35
+ const options = (0, index_7.Discard)(type, [index_6.TransformKind, '$id', 'required', 'properties']);
36
+ const properties = FromProperties(type['properties']);
37
+ return (0, index_2.Object)(properties, options);
38
+ }
39
+ // prettier-ignore
40
+ function FromRest(types) {
41
+ return types.map(type => RequiredResolve(type));
32
42
  }
33
43
  // ------------------------------------------------------------------
34
44
  // RequiredResolve
35
45
  // ------------------------------------------------------------------
36
46
  // prettier-ignore
37
- function RequiredResolve(T) {
38
- return ((0, kind_1.IsIntersect)(T) ? (0, index_1.Intersect)(FromRest(T.allOf)) :
39
- (0, kind_1.IsUnion)(T) ? (0, index_2.Union)(FromRest(T.anyOf)) :
40
- (0, kind_1.IsObject)(T) ? FromObject(T) :
41
- (0, index_3.Object)({}));
47
+ function RequiredResolve(type) {
48
+ return ((0, kind_1.IsComputed)(type) ? FromComputed(type.target, type.parameters) :
49
+ (0, kind_1.IsRef)(type) ? FromRef(type.$ref) :
50
+ (0, kind_1.IsIntersect)(type) ? (0, index_3.Intersect)(FromRest(type.allOf)) :
51
+ (0, kind_1.IsUnion)(type) ? (0, index_4.Union)(FromRest(type.anyOf)) :
52
+ (0, kind_1.IsObject)(type) ? FromObject(type) :
53
+ (0, index_2.Object)({}));
42
54
  }
43
55
  /** `[Json]` Constructs a type where all properties are required */
44
- function Required(T, options) {
45
- if ((0, kind_1.IsMappedResult)(T)) {
46
- return (0, required_from_mapped_result_1.RequiredFromMappedResult)(T, options);
56
+ function Required(type, options) {
57
+ if ((0, kind_1.IsMappedResult)(type)) {
58
+ return (0, required_from_mapped_result_1.RequiredFromMappedResult)(type, options);
47
59
  }
48
60
  else {
49
61
  // special: mapping types require overridable options
50
- return (0, type_1.CreateType)({ ...RequiredResolve(T), ...options });
62
+ return (0, type_1.CreateType)({ ...RequiredResolve(type), ...options });
51
63
  }
52
64
  }
@@ -12,5 +12,5 @@ export interface TTuple<T extends TSchema[] = TSchema[]> extends TSchema {
12
12
  maxItems: number;
13
13
  }
14
14
  /** `[Json]` Creates a Tuple type */
15
- export declare function Tuple<T extends TSchema[]>(items: [...T], options?: SchemaOptions): TTuple<T>;
15
+ export declare function Tuple<Types extends TSchema[]>(types: [...Types], options?: SchemaOptions): TTuple<Types>;
16
16
  export {};
@@ -5,9 +5,9 @@ exports.Tuple = Tuple;
5
5
  const type_1 = require("../create/type");
6
6
  const index_1 = require("../symbols/index");
7
7
  /** `[Json]` Creates a Tuple type */
8
- function Tuple(items, options) {
8
+ function Tuple(types, options) {
9
9
  // prettier-ignore
10
- return (0, type_1.CreateType)(items.length > 0 ?
11
- { [index_1.Kind]: 'Tuple', type: 'array', items, additionalItems: false, minItems: items.length, maxItems: items.length } :
12
- { [index_1.Kind]: 'Tuple', type: 'array', minItems: items.length, maxItems: items.length }, options);
10
+ return (0, type_1.CreateType)(types.length > 0 ?
11
+ { [index_1.Kind]: 'Tuple', type: 'array', items: types, additionalItems: false, minItems: types.length, maxItems: types.length } :
12
+ { [index_1.Kind]: 'Tuple', type: 'array', minItems: types.length, maxItems: types.length }, options);
13
13
  }
@@ -20,33 +20,33 @@ import { type TVoid } from '../void/index';
20
20
  /** JavaScript Type Builder with Static Resolution for TypeScript */
21
21
  export declare class JavaScriptTypeBuilder extends JsonTypeBuilder {
22
22
  /** `[JavaScript]` Creates a AsyncIterator type */
23
- AsyncIterator<T extends TSchema>(items: T, options?: SchemaOptions): TAsyncIterator<T>;
23
+ AsyncIterator<Type extends TSchema>(items: Type, options?: SchemaOptions): TAsyncIterator<Type>;
24
24
  /** `[JavaScript]` Constructs a type by recursively unwrapping Promise types */
25
- Awaited<T extends TSchema>(schema: T, options?: SchemaOptions): TAwaited<T>;
25
+ Awaited<Type extends TSchema>(schema: Type, options?: SchemaOptions): TAwaited<Type>;
26
26
  /** `[JavaScript]` Creates a BigInt type */
27
27
  BigInt(options?: BigIntOptions): TBigInt;
28
28
  /** `[JavaScript]` Extracts the ConstructorParameters from the given Constructor type */
29
- ConstructorParameters<T extends TConstructor<TSchema[], TSchema>>(schema: T, options?: SchemaOptions): TConstructorParameters<T>;
29
+ ConstructorParameters<Type extends TConstructor>(schema: Type, options?: SchemaOptions): TConstructorParameters<Type>;
30
30
  /** `[JavaScript]` Creates a Constructor type */
31
- Constructor<T extends TSchema[], U extends TSchema>(parameters: [...T], returns: U, options?: SchemaOptions): TConstructor<T, U>;
31
+ Constructor<Parameters extends TSchema[], InstanceType extends TSchema>(parameters: [...Parameters], instanceType: InstanceType, options?: SchemaOptions): TConstructor<Parameters, InstanceType>;
32
32
  /** `[JavaScript]` Creates a Date type */
33
33
  Date(options?: DateOptions): TDate;
34
34
  /** `[JavaScript]` Creates a Function type */
35
- Function<T extends TSchema[], U extends TSchema>(parameters: [...T], returns: U, options?: SchemaOptions): TFunction<T, U>;
35
+ Function<Parameters extends TSchema[], ReturnType extends TSchema>(parameters: [...Parameters], returnType: ReturnType, options?: SchemaOptions): TFunction<Parameters, ReturnType>;
36
36
  /** `[JavaScript]` Extracts the InstanceType from the given Constructor type */
37
- InstanceType<T extends TConstructor<any[], any>>(schema: T, options?: SchemaOptions): TInstanceType<T>;
37
+ InstanceType<Type extends TConstructor>(schema: Type, options?: SchemaOptions): TInstanceType<Type>;
38
38
  /** `[JavaScript]` Creates an Iterator type */
39
- Iterator<T extends TSchema>(items: T, options?: SchemaOptions): TIterator<T>;
39
+ Iterator<Type extends TSchema>(items: Type, options?: SchemaOptions): TIterator<Type>;
40
40
  /** `[JavaScript]` Extracts the Parameters from the given Function type */
41
- Parameters<T extends TFunction<TSchema[], TSchema>>(schema: T, options?: SchemaOptions): TParameters<T>;
41
+ Parameters<Type extends TFunction>(schema: Type, options?: SchemaOptions): TParameters<Type>;
42
42
  /** `[JavaScript]` Creates a Promise type */
43
- Promise<T extends TSchema>(item: T, options?: SchemaOptions): TPromise<T>;
43
+ Promise<Type extends TSchema>(item: Type, options?: SchemaOptions): TPromise<Type>;
44
44
  /** `[JavaScript]` Creates a RegExp type */
45
45
  RegExp(pattern: string, options?: RegExpOptions): TRegExp;
46
46
  /** `[JavaScript]` Creates a RegExp type */
47
47
  RegExp(regex: RegExp, options?: RegExpOptions): TRegExp;
48
48
  /** `[JavaScript]` Extracts the ReturnType from the given Function type */
49
- ReturnType<T extends TFunction<any[], any>>(schema: T, options?: SchemaOptions): TReturnType<T>;
49
+ ReturnType<Type extends TFunction>(type: Type, options?: SchemaOptions): TReturnType<Type>;
50
50
  /** `[JavaScript]` Creates a Symbol type */
51
51
  Symbol(options?: SchemaOptions): TSymbol;
52
52
  /** `[JavaScript]` Creates a Undefined type */
@@ -39,16 +39,16 @@ class JavaScriptTypeBuilder extends json_1.JsonTypeBuilder {
39
39
  return (0, index_5.ConstructorParameters)(schema, options);
40
40
  }
41
41
  /** `[JavaScript]` Creates a Constructor type */
42
- Constructor(parameters, returns, options) {
43
- return (0, index_4.Constructor)(parameters, returns, options);
42
+ Constructor(parameters, instanceType, options) {
43
+ return (0, index_4.Constructor)(parameters, instanceType, options);
44
44
  }
45
45
  /** `[JavaScript]` Creates a Date type */
46
46
  Date(options = {}) {
47
47
  return (0, index_6.Date)(options);
48
48
  }
49
49
  /** `[JavaScript]` Creates a Function type */
50
- Function(parameters, returns, options) {
51
- return (0, index_7.Function)(parameters, returns, options);
50
+ Function(parameters, returnType, options) {
51
+ return (0, index_7.Function)(parameters, returnType, options);
52
52
  }
53
53
  /** `[JavaScript]` Extracts the InstanceType from the given Constructor type */
54
54
  InstanceType(schema, options) {
@@ -71,8 +71,8 @@ class JavaScriptTypeBuilder extends json_1.JsonTypeBuilder {
71
71
  return (0, index_12.RegExp)(unresolved, options);
72
72
  }
73
73
  /** `[JavaScript]` Extracts the ReturnType from the given Function type */
74
- ReturnType(schema, options) {
75
- return (0, index_13.ReturnType)(schema, options);
74
+ ReturnType(type, options) {
75
+ return (0, index_13.ReturnType)(type, options);
76
76
  }
77
77
  /** `[JavaScript]` Creates a Symbol type */
78
78
  Symbol(options) {
@@ -7,11 +7,11 @@ import { type TEnum, type TEnumKey, type TEnumValue } from '../enum/index';
7
7
  import { type TExclude, type TExcludeFromMappedResult, type TExcludeFromTemplateLiteral } from '../exclude/index';
8
8
  import { type TExtends, type TExtendsFromMappedKey, type TExtendsFromMappedResult } from '../extends/index';
9
9
  import { type TExtract, type TExtractFromMappedResult, type TExtractFromTemplateLiteral } from '../extract/index';
10
- import { TIndex, type TIndexPropertyKeys, type TIndexFromMappedKey, type TIndexFromMappedResult } from '../indexed/index';
10
+ import { TIndex, type TIndexPropertyKeys } from '../indexed/index';
11
11
  import { type IntegerOptions, type TInteger } from '../integer/index';
12
12
  import { Intersect, type IntersectOptions } from '../intersect/index';
13
13
  import { type TCapitalize, type TUncapitalize, type TLowercase, type TUppercase } from '../intrinsic/index';
14
- import { type TKeyOf, type TKeyOfFromMappedResult } from '../keyof/index';
14
+ import { type TKeyOf } from '../keyof/index';
15
15
  import { type TLiteral, type TLiteralValue } from '../literal/index';
16
16
  import { type TMappedFunction, type TMapped, type TMappedResult } from '../mapped/index';
17
17
  import { type TNever } from '../never/index';
@@ -21,10 +21,10 @@ import { type TMappedKey } from '../mapped/index';
21
21
  import { TModule } from '../module/index';
22
22
  import { type TNumber, type NumberOptions } from '../number/index';
23
23
  import { type TObject, type TProperties, type ObjectOptions } from '../object/index';
24
- import { type TOmit, type TOmitFromMappedKey, type TOmitFromMappedResult } from '../omit/index';
24
+ import { type TOmit } from '../omit/index';
25
25
  import { type TOptionalWithFlag, type TOptionalFromMappedResult } from '../optional/index';
26
26
  import { type TPartial, type TPartialFromMappedResult } from '../partial/index';
27
- import { type TPick, type TPickFromMappedKey, type TPickFromMappedResult } from '../pick/index';
27
+ import { type TPick } from '../pick/index';
28
28
  import { type TReadonlyWithFlag, type TReadonlyFromMappedResult } from '../readonly/index';
29
29
  import { type TReadonlyOptional } from '../readonly-optional/index';
30
30
  import { type TRecordOrObject } from '../record/index';
@@ -43,27 +43,27 @@ import { type TUnsafe, type UnsafeOptions } from '../unsafe/index';
43
43
  /** Json Type Builder with Static Resolution for TypeScript */
44
44
  export declare class JsonTypeBuilder {
45
45
  /** `[Json]` Creates a Readonly and Optional property */
46
- ReadonlyOptional<T extends TSchema>(schema: T): TReadonlyOptional<T>;
46
+ ReadonlyOptional<Type extends TSchema>(type: Type): TReadonlyOptional<Type>;
47
47
  /** `[Json]` Creates a Readonly property */
48
- Readonly<T extends TMappedResult, F extends boolean>(schema: T, enable: F): TReadonlyFromMappedResult<T, F>;
48
+ Readonly<Type extends TMappedResult, Flag extends boolean>(type: Type, enable: Flag): TReadonlyFromMappedResult<Type, Flag>;
49
49
  /** `[Json]` Creates a Readonly property */
50
- Readonly<T extends TSchema, F extends boolean>(schema: T, enable: F): TReadonlyWithFlag<T, F>;
50
+ Readonly<Type extends TSchema, Flag extends boolean>(type: Type, enable: Flag): TReadonlyWithFlag<Type, Flag>;
51
51
  /** `[Json]` Creates a Optional property */
52
- Readonly<T extends TMappedResult>(schema: T): TReadonlyFromMappedResult<T, true>;
52
+ Readonly<Type extends TMappedResult>(type: Type): TReadonlyFromMappedResult<Type, true>;
53
53
  /** `[Json]` Creates a Readonly property */
54
- Readonly<T extends TSchema>(schema: T): TReadonlyWithFlag<T, true>;
54
+ Readonly<Type extends TSchema>(type: Type): TReadonlyWithFlag<Type, true>;
55
55
  /** `[Json]` Creates a Optional property */
56
- Optional<T extends TMappedResult, F extends boolean>(schema: T, enable: F): TOptionalFromMappedResult<T, F>;
56
+ Optional<Type extends TMappedResult, Flag extends boolean>(type: Type, enable: Flag): TOptionalFromMappedResult<Type, Flag>;
57
57
  /** `[Json]` Creates a Optional property */
58
- Optional<T extends TSchema, F extends boolean>(schema: T, enable: F): TOptionalWithFlag<T, F>;
58
+ Optional<Type extends TSchema, Flag extends boolean>(type: Type, enable: Flag): TOptionalWithFlag<Type, Flag>;
59
59
  /** `[Json]` Creates a Optional property */
60
- Optional<T extends TMappedResult>(schema: T): TOptionalFromMappedResult<T, true>;
60
+ Optional<Type extends TMappedResult>(type: Type): TOptionalFromMappedResult<Type, true>;
61
61
  /** `[Json]` Creates a Optional property */
62
- Optional<T extends TSchema>(schema: T): TOptionalWithFlag<T, true>;
62
+ Optional<Type extends TSchema>(type: Type): TOptionalWithFlag<Type, true>;
63
63
  /** `[Json]` Creates an Any type */
64
64
  Any(options?: SchemaOptions): TAny;
65
65
  /** `[Json]` Creates an Array type */
66
- Array<T extends TSchema>(schema: T, options?: ArrayOptions): TArray<T>;
66
+ Array<Type extends TSchema>(items: Type, options?: ArrayOptions): TArray<Type>;
67
67
  /** `[Json]` Creates a Boolean type */
68
68
  Boolean(options?: SchemaOptions): TBoolean;
69
69
  /** `[Json]` Intrinsic function to Capitalize LiteralString types */
@@ -93,25 +93,23 @@ export declare class JsonTypeBuilder {
93
93
  /** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
94
94
  Extract<L extends TSchema, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtract<L, R>;
95
95
  /** `[Json]` Returns an Indexed property type for the given keys */
96
- Index<T extends TSchema, K extends TMappedResult>(T: T, K: K, options?: SchemaOptions): TIndexFromMappedResult<T, K>;
96
+ Index<Type extends TSchema, PropertyKeys extends PropertyKey[]>(type: Type, key: readonly [...PropertyKeys], options?: SchemaOptions): TIndex<Type, PropertyKeys>;
97
97
  /** `[Json]` Returns an Indexed property type for the given keys */
98
- Index<T extends TSchema, K extends TMappedKey>(T: T, K: K, options?: SchemaOptions): TIndexFromMappedKey<T, K>;
98
+ Index<Type extends TSchema, Key extends TMappedKey>(type: Type, key: Key, options?: SchemaOptions): TIndex<Type, Key>;
99
99
  /** `[Json]` Returns an Indexed property type for the given keys */
100
- Index<T extends TSchema, K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TIndex<T, I>;
100
+ Index<Type extends TSchema, Key extends TMappedResult>(type: Type, key: Key, options?: SchemaOptions): TIndex<Type, Key>;
101
101
  /** `[Json]` Returns an Indexed property type for the given keys */
102
- Index<T extends TSchema, K extends PropertyKey[]>(T: T, K: readonly [...K], options?: SchemaOptions): TIndex<T, K>;
102
+ Index<Type extends TSchema, Key extends TSchema>(type: Type, key: Key, options?: SchemaOptions): TIndex<Type, Key>;
103
103
  /** `[Json]` Creates an Integer type */
104
104
  Integer(options?: IntegerOptions): TInteger;
105
105
  /** `[Json]` Creates an Intersect type */
106
- Intersect<T extends TSchema[]>(T: [...T], options?: IntersectOptions): Intersect<T>;
106
+ Intersect<Types extends TSchema[]>(types: [...Types], options?: IntersectOptions): Intersect<Types>;
107
107
  /** `[Json]` Creates a KeyOf type */
108
- KeyOf<T extends TMappedResult>(schema: T, options?: SchemaOptions): TKeyOfFromMappedResult<T>;
109
- /** `[Json]` Creates a KeyOf type */
110
- KeyOf<T extends TSchema>(schema: T, options?: SchemaOptions): TKeyOf<T>;
108
+ KeyOf<Type extends TSchema>(type: Type, options?: SchemaOptions): TKeyOf<Type>;
111
109
  /** `[Json]` Creates a Literal type */
112
- Literal<T extends TLiteralValue>(value: T, options?: SchemaOptions): TLiteral<T>;
110
+ Literal<LiteralValue extends TLiteralValue>(literalValue: LiteralValue, options?: SchemaOptions): TLiteral<LiteralValue>;
113
111
  /** `[Json]` Intrinsic function to Lowercase LiteralString types */
114
- Lowercase<T extends TSchema>(schema: T, options?: SchemaOptions): TLowercase<T>;
112
+ Lowercase<Type extends TSchema>(type: Type, options?: SchemaOptions): TLowercase<Type>;
115
113
  /** `[Json]` Creates a Mapped object type */
116
114
  Mapped<K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>, F extends TMappedFunction<I> = TMappedFunction<I>, R extends TMapped<I, F> = TMapped<I, F>>(key: K, map: F, options?: ObjectOptions): R;
117
115
  /** `[Json]` Creates a Mapped object type */
@@ -121,59 +119,51 @@ export declare class JsonTypeBuilder {
121
119
  /** `[Json]` Creates a Never type */
122
120
  Never(options?: SchemaOptions): TNever;
123
121
  /** `[Json]` Creates a Not type */
124
- Not<T extends TSchema>(schema: T, options?: SchemaOptions): TNot<T>;
122
+ Not<T extends TSchema>(type: T, options?: SchemaOptions): TNot<T>;
125
123
  /** `[Json]` Creates a Null type */
126
124
  Null(options?: SchemaOptions): TNull;
127
125
  /** `[Json]` Creates a Number type */
128
126
  Number(options?: NumberOptions): TNumber;
129
127
  /** `[Json]` Creates an Object type */
130
128
  Object<T extends TProperties>(properties: T, options?: ObjectOptions): TObject<T>;
131
- /** `[Json]` Constructs a type whose keys are omitted from the given type */
132
- Omit<T extends TMappedResult, K extends PropertyKey[]>(T: T, K: [...K], options?: SchemaOptions): TOmitFromMappedResult<T, K>;
133
- /** `[Json]` Constructs a type whose keys are omitted from the given type */
134
- Omit<T extends TSchema, K extends TMappedKey>(T: T, K: K, options?: SchemaOptions): TOmitFromMappedKey<T, K>;
135
- /** `[Json]` Constructs a type whose keys are omitted from the given type */
136
- Omit<T extends TSchema, K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TOmit<T, I>;
137
- /** `[Json]` Constructs a type whose keys are omitted from the given type */
138
- Omit<T extends TSchema, K extends PropertyKey[]>(T: T, K: readonly [...K], options?: SchemaOptions): TOmit<T, K>;
139
- /** `[Json]` Constructs a type where all properties are optional */
140
- Partial<T extends TMappedResult>(T: T, options?: SchemaOptions): TPartialFromMappedResult<T>;
141
- /** `[Json]` Constructs a type where all properties are optional */
142
- Partial<T extends TSchema>(schema: T, options?: SchemaOptions): TPartial<T>;
143
129
  /** `[Json]` Constructs a type whose keys are picked from the given type */
144
- Pick<T extends TMappedResult, K extends PropertyKey[]>(T: T, K: [...K], options?: SchemaOptions): TPickFromMappedResult<T, K>;
130
+ Omit<Type extends TSchema, Key extends PropertyKey[]>(type: Type, key: readonly [...Key], options?: SchemaOptions): TOmit<Type, Key>;
145
131
  /** `[Json]` Constructs a type whose keys are picked from the given type */
146
- Pick<T extends TSchema, K extends TMappedKey>(T: T, K: K, options?: SchemaOptions): TPickFromMappedKey<T, K>;
132
+ Omit<Type extends TSchema, Key extends TSchema>(type: Type, key: Key, options?: SchemaOptions): TOmit<Type, Key>;
133
+ /** `[Json]` Constructs a type where all properties are optional */
134
+ Partial<MappedResult extends TMappedResult>(type: MappedResult, options?: SchemaOptions): TPartialFromMappedResult<MappedResult>;
135
+ /** `[Json]` Constructs a type where all properties are optional */
136
+ Partial<Type extends TSchema>(type: Type, options?: SchemaOptions): TPartial<Type>;
147
137
  /** `[Json]` Constructs a type whose keys are picked from the given type */
148
- Pick<T extends TSchema, K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TPick<T, I>;
138
+ Pick<Type extends TSchema, Key extends PropertyKey[]>(type: Type, key: readonly [...Key], options?: SchemaOptions): TPick<Type, Key>;
149
139
  /** `[Json]` Constructs a type whose keys are picked from the given type */
150
- Pick<T extends TSchema, K extends PropertyKey[]>(T: T, K: readonly [...K], options?: SchemaOptions): TPick<T, K>;
140
+ Pick<Type extends TSchema, Key extends TSchema>(type: Type, key: Key, options?: SchemaOptions): TPick<Type, Key>;
151
141
  /** `[Json]` Creates a Record type */
152
- Record<K extends TSchema, T extends TSchema>(key: K, schema: T, options?: ObjectOptions): TRecordOrObject<K, T>;
142
+ Record<Key extends TSchema, Value extends TSchema>(key: Key, value: Value, options?: ObjectOptions): TRecordOrObject<Key, Value>;
153
143
  /** `[Json]` Creates a Recursive type */
154
144
  Recursive<T extends TSchema>(callback: (thisType: TThis) => T, options?: SchemaOptions): TRecursive<T>;
155
145
  /** `[Json]` Creates a Ref type. */
156
146
  Ref<Ref extends string>($ref: Ref, options?: SchemaOptions): TRef<Ref>;
157
147
  /** `[Json]` Constructs a type where all properties are required */
158
- Required<T extends TMappedResult>(T: T, options?: SchemaOptions): TRequiredFromMappedResult<T>;
148
+ Required<MappedResult extends TMappedResult>(type: MappedResult, options?: SchemaOptions): TRequiredFromMappedResult<MappedResult>;
159
149
  /** `[Json]` Constructs a type where all properties are required */
160
- Required<T extends TSchema>(schema: T, options?: SchemaOptions): TRequired<T>;
150
+ Required<Type extends TSchema>(type: Type, options?: SchemaOptions): TRequired<Type>;
161
151
  /** `[Json]` Extracts interior Rest elements from Tuple, Intersect and Union types */
162
- Rest<T extends TSchema>(schema: T): TRest<T>;
152
+ Rest<Type extends TSchema>(type: Type): TRest<Type>;
163
153
  /** `[Json]` Creates a String type */
164
154
  String(options?: StringOptions): TString;
165
155
  /** `[Json]` Creates a TemplateLiteral type from template dsl string */
166
- TemplateLiteral<T extends string>(syntax: T, options?: SchemaOptions): TTemplateLiteralSyntax<T>;
156
+ TemplateLiteral<Syntax extends string>(syntax: Syntax, options?: SchemaOptions): TTemplateLiteralSyntax<Syntax>;
167
157
  /** `[Json]` Creates a TemplateLiteral type */
168
- TemplateLiteral<T extends TTemplateLiteralKind[]>(kinds: [...T], options?: SchemaOptions): TTemplateLiteral<T>;
158
+ TemplateLiteral<Kinds extends TTemplateLiteralKind[]>(kinds: [...Kinds], options?: SchemaOptions): TTemplateLiteral<Kinds>;
169
159
  /** `[Json]` Creates a Transform type */
170
- Transform<I extends TSchema>(schema: I): TransformDecodeBuilder<I>;
160
+ Transform<Type extends TSchema>(type: Type): TransformDecodeBuilder<Type>;
171
161
  /** `[Json]` Creates a Tuple type */
172
- Tuple<T extends TSchema[]>(items: [...T], options?: SchemaOptions): TTuple<T>;
162
+ Tuple<Types extends TSchema[]>(types: [...Types], options?: SchemaOptions): TTuple<Types>;
173
163
  /** `[Json]` Intrinsic function to Uncapitalize LiteralString types */
174
- Uncapitalize<T extends TSchema>(schema: T, options?: SchemaOptions): TUncapitalize<T>;
164
+ Uncapitalize<Type extends TSchema>(type: Type, options?: SchemaOptions): TUncapitalize<Type>;
175
165
  /** `[Json]` Creates a Union type */
176
- Union<T extends TSchema[]>(schemas: [...T], options?: SchemaOptions): Union<T>;
166
+ Union<Types extends TSchema[]>(types: [...Types], options?: SchemaOptions): Union<Types>;
177
167
  /** `[Json]` Creates an Unknown type */
178
168
  Unknown(options?: SchemaOptions): TUnknown;
179
169
  /** `[Json]` Creates a Unsafe type that will infers as the generic argument T */
@@ -48,16 +48,16 @@ class JsonTypeBuilder {
48
48
  // Modifiers
49
49
  // ------------------------------------------------------------------------
50
50
  /** `[Json]` Creates a Readonly and Optional property */
51
- ReadonlyOptional(schema) {
52
- return (0, index_28.ReadonlyOptional)(schema);
51
+ ReadonlyOptional(type) {
52
+ return (0, index_28.ReadonlyOptional)(type);
53
53
  }
54
54
  /** `[Json]` Creates a Readonly property */
55
- Readonly(schema, enable) {
56
- return (0, index_27.Readonly)(schema, enable ?? true);
55
+ Readonly(type, enable) {
56
+ return (0, index_27.Readonly)(type, enable ?? true);
57
57
  }
58
58
  /** `[Json]` Creates a Optional property */
59
- Optional(schema, enable) {
60
- return (0, index_24.Optional)(schema, enable ?? true);
59
+ Optional(type, enable) {
60
+ return (0, index_24.Optional)(type, enable ?? true);
61
61
  }
62
62
  // ------------------------------------------------------------------------
63
63
  // Types
@@ -67,8 +67,8 @@ class JsonTypeBuilder {
67
67
  return (0, index_1.Any)(options);
68
68
  }
69
69
  /** `[Json]` Creates an Array type */
70
- Array(schema, options) {
71
- return (0, index_2.Array)(schema, options);
70
+ Array(items, options) {
71
+ return (0, index_2.Array)(items, options);
72
72
  }
73
73
  /** `[Json]` Creates a Boolean type */
74
74
  Boolean(options) {
@@ -103,28 +103,28 @@ class JsonTypeBuilder {
103
103
  return (0, index_9.Extract)(type, union, options);
104
104
  }
105
105
  /** `[Json]` Returns an Indexed property type for the given keys */
106
- Index(schema, unresolved, options) {
107
- return (0, index_10.Index)(schema, unresolved, options);
106
+ Index(type, key, options) {
107
+ return (0, index_10.Index)(type, key, options);
108
108
  }
109
109
  /** `[Json]` Creates an Integer type */
110
110
  Integer(options) {
111
111
  return (0, index_11.Integer)(options);
112
112
  }
113
113
  /** `[Json]` Creates an Intersect type */
114
- Intersect(T, options) {
115
- return (0, index_12.Intersect)(T, options);
114
+ Intersect(types, options) {
115
+ return (0, index_12.Intersect)(types, options);
116
116
  }
117
117
  /** `[Json]` Creates a KeyOf type */
118
- KeyOf(schema, options) {
119
- return (0, index_14.KeyOf)(schema, options);
118
+ KeyOf(type, options) {
119
+ return (0, index_14.KeyOf)(type, options);
120
120
  }
121
121
  /** `[Json]` Creates a Literal type */
122
- Literal(value, options) {
123
- return (0, index_15.Literal)(value, options);
122
+ Literal(literalValue, options) {
123
+ return (0, index_15.Literal)(literalValue, options);
124
124
  }
125
125
  /** `[Json]` Intrinsic function to Lowercase LiteralString types */
126
- Lowercase(schema, options) {
127
- return (0, index_13.Lowercase)(schema, options);
126
+ Lowercase(type, options) {
127
+ return (0, index_13.Lowercase)(type, options);
128
128
  }
129
129
  /** `[Json]` Creates a Mapped object type */
130
130
  Mapped(key, map, options) {
@@ -139,8 +139,8 @@ class JsonTypeBuilder {
139
139
  return (0, index_17.Never)(options);
140
140
  }
141
141
  /** `[Json]` Creates a Not type */
142
- Not(schema, options) {
143
- return (0, index_18.Not)(schema, options);
142
+ Not(type, options) {
143
+ return (0, index_18.Not)(type, options);
144
144
  }
145
145
  /** `[Json]` Creates a Null type */
146
146
  Null(options) {
@@ -155,20 +155,20 @@ class JsonTypeBuilder {
155
155
  return (0, index_22.Object)(properties, options);
156
156
  }
157
157
  /** `[Json]` Constructs a type whose keys are omitted from the given type */
158
- Omit(schema, unresolved, options) {
159
- return (0, index_23.Omit)(schema, unresolved, options);
158
+ Omit(schema, selector, options) {
159
+ return (0, index_23.Omit)(schema, selector, options);
160
160
  }
161
161
  /** `[Json]` Constructs a type where all properties are optional */
162
- Partial(schema, options) {
163
- return (0, index_25.Partial)(schema, options);
162
+ Partial(type, options) {
163
+ return (0, index_25.Partial)(type, options);
164
164
  }
165
165
  /** `[Json]` Constructs a type whose keys are picked from the given type */
166
- Pick(schema, unresolved, options) {
167
- return (0, index_26.Pick)(schema, unresolved, options);
166
+ Pick(type, key, options) {
167
+ return (0, index_26.Pick)(type, key, options);
168
168
  }
169
169
  /** `[Json]` Creates a Record type */
170
- Record(key, schema, options) {
171
- return (0, index_29.Record)(key, schema, options);
170
+ Record(key, value, options) {
171
+ return (0, index_29.Record)(key, value, options);
172
172
  }
173
173
  /** `[Json]` Creates a Recursive type */
174
174
  Recursive(callback, options) {
@@ -179,12 +179,12 @@ class JsonTypeBuilder {
179
179
  return (0, index_31.Ref)($ref, options);
180
180
  }
181
181
  /** `[Json]` Constructs a type where all properties are required */
182
- Required(schema, options) {
183
- return (0, index_32.Required)(schema, options);
182
+ Required(type, options) {
183
+ return (0, index_32.Required)(type, options);
184
184
  }
185
185
  /** `[Json]` Extracts interior Rest elements from Tuple, Intersect and Union types */
186
- Rest(schema) {
187
- return (0, index_33.Rest)(schema);
186
+ Rest(type) {
187
+ return (0, index_33.Rest)(type);
188
188
  }
189
189
  /** `[Json]` Creates a String type */
190
190
  String(options) {
@@ -195,20 +195,20 @@ class JsonTypeBuilder {
195
195
  return (0, index_35.TemplateLiteral)(unresolved, options);
196
196
  }
197
197
  /** `[Json]` Creates a Transform type */
198
- Transform(schema) {
199
- return (0, index_36.Transform)(schema);
198
+ Transform(type) {
199
+ return (0, index_36.Transform)(type);
200
200
  }
201
201
  /** `[Json]` Creates a Tuple type */
202
- Tuple(items, options) {
203
- return (0, index_37.Tuple)(items, options);
202
+ Tuple(types, options) {
203
+ return (0, index_37.Tuple)(types, options);
204
204
  }
205
205
  /** `[Json]` Intrinsic function to Uncapitalize LiteralString types */
206
- Uncapitalize(schema, options) {
207
- return (0, index_13.Uncapitalize)(schema, options);
206
+ Uncapitalize(type, options) {
207
+ return (0, index_13.Uncapitalize)(type, options);
208
208
  }
209
209
  /** `[Json]` Creates a Union type */
210
- Union(schemas, options) {
211
- return (0, index_38.Union)(schemas, options);
210
+ Union(types, options) {
211
+ return (0, index_38.Union)(types, options);
212
212
  }
213
213
  /** `[Json]` Creates an Unknown type */
214
214
  Unknown(options) {
@@ -3,11 +3,11 @@ 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 type { TUnion } from './union-type';
6
- type TIsUnionOptional<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<TSchema> ? true : TIsUnionOptional<R> : false);
7
- 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);
8
- 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);
9
- type TResolveUnion<T extends TSchema[], R extends TSchema[] = TRemoveOptionalFromRest<T>> = (TIsUnionOptional<T> extends true ? TOptional<TUnion<R>> : TUnion<R>);
10
- export type TUnionEvaluated<T extends TSchema[]> = (T extends [] ? TNever : T extends [TSchema] ? T[0] : TResolveUnion<T>);
6
+ type TIsUnionOptional<Types extends TSchema[]> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? Left extends TOptional<TSchema> ? true : TIsUnionOptional<Right> : false);
7
+ type TRemoveOptionalFromRest<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? Left extends TOptional<infer S extends TSchema> ? TRemoveOptionalFromRest<Right, [...Result, TRemoveOptionalFromType<S>]> : TRemoveOptionalFromRest<Right, [...Result, Left]> : Result);
8
+ type TRemoveOptionalFromType<Type extends TSchema> = (Type extends TReadonly<infer Type extends TSchema> ? TReadonly<TRemoveOptionalFromType<Type>> : Type extends TOptional<infer Type extends TSchema> ? TRemoveOptionalFromType<Type> : Type);
9
+ type TResolveUnion<Types extends TSchema[], Result extends TSchema[] = TRemoveOptionalFromRest<Types>, IsOptional extends boolean = TIsUnionOptional<Types>> = (IsOptional extends true ? TOptional<TUnion<Result>> : TUnion<Result>);
10
+ export type TUnionEvaluated<Types extends TSchema[]> = (Types extends [TSchema] ? Types[0] : Types extends [] ? TNever : TResolveUnion<Types>);
11
11
  /** `[Json]` Creates an evaluated Union type */
12
- export declare function UnionEvaluated<T extends TSchema[], R = TUnionEvaluated<T>>(T: [...T], options?: SchemaOptions): R;
12
+ export declare function UnionEvaluated<Types extends TSchema[], Result = TUnionEvaluated<Types>>(T: [...Types], options?: SchemaOptions): Result;
13
13
  export {};
@@ -13,27 +13,28 @@ const union_create_1 = require("./union-create");
13
13
  // ------------------------------------------------------------------
14
14
  const kind_1 = require("../guard/kind");
15
15
  // prettier-ignore
16
- function IsUnionOptional(T) {
17
- return T.some(L => (0, kind_1.IsOptional)(L));
16
+ function IsUnionOptional(types) {
17
+ return types.some(type => (0, kind_1.IsOptional)(type));
18
18
  }
19
19
  // prettier-ignore
20
- function RemoveOptionalFromRest(T) {
21
- return T.map(L => (0, kind_1.IsOptional)(L) ? RemoveOptionalFromType(L) : L);
20
+ function RemoveOptionalFromRest(types) {
21
+ return types.map(left => (0, kind_1.IsOptional)(left) ? RemoveOptionalFromType(left) : left);
22
22
  }
23
23
  // prettier-ignore
24
24
  function RemoveOptionalFromType(T) {
25
25
  return ((0, index_2.Discard)(T, [index_1.OptionalKind]));
26
26
  }
27
27
  // prettier-ignore
28
- function ResolveUnion(T, options) {
29
- return (IsUnionOptional(T)
30
- ? (0, index_4.Optional)((0, union_create_1.UnionCreate)(RemoveOptionalFromRest(T), options))
31
- : (0, union_create_1.UnionCreate)(RemoveOptionalFromRest(T), options));
28
+ function ResolveUnion(types, options) {
29
+ const isOptional = IsUnionOptional(types);
30
+ return (isOptional
31
+ ? (0, index_4.Optional)((0, union_create_1.UnionCreate)(RemoveOptionalFromRest(types), options))
32
+ : (0, union_create_1.UnionCreate)(RemoveOptionalFromRest(types), options));
32
33
  }
33
34
  /** `[Json]` Creates an evaluated Union type */
34
35
  function UnionEvaluated(T, options) {
35
36
  // prettier-ignore
36
- return (T.length === 0 ? (0, index_3.Never)(options) :
37
- T.length === 1 ? (0, type_1.CreateType)(T[0], options) :
37
+ return (T.length === 1 ? (0, type_1.CreateType)(T[0], options) :
38
+ T.length === 0 ? (0, index_3.Never)(options) :
38
39
  ResolveUnion(T, options));
39
40
  }
@@ -3,4 +3,4 @@ import { type TNever } from '../never/index';
3
3
  import type { TUnion } from './union-type';
4
4
  export type Union<T extends TSchema[]> = (T extends [] ? TNever : T extends [TSchema] ? T[0] : TUnion<T>);
5
5
  /** `[Json]` Creates a Union type */
6
- export declare function Union<T extends TSchema[]>(T: [...T], options?: SchemaOptions): Union<T>;
6
+ export declare function Union<Types extends TSchema[]>(types: [...Types], options?: SchemaOptions): Union<Types>;
@@ -6,9 +6,9 @@ const index_1 = require("../never/index");
6
6
  const type_1 = require("../create/type");
7
7
  const union_create_1 = require("./union-create");
8
8
  /** `[Json]` Creates a Union type */
9
- function Union(T, options) {
9
+ function Union(types, options) {
10
10
  // prettier-ignore
11
- return (T.length === 0 ? (0, index_1.Never)(options) :
12
- T.length === 1 ? (0, type_1.CreateType)(T[0], options) :
13
- (0, union_create_1.UnionCreate)(T, options));
11
+ return (types.length === 0 ? (0, index_1.Never)(options) :
12
+ types.length === 1 ? (0, type_1.CreateType)(types[0], options) :
13
+ (0, union_create_1.UnionCreate)(types, options));
14
14
  }