@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
@@ -1,48 +1,60 @@
1
1
  import { CreateType } from '../create/type.mjs';
2
+ import { Computed } from '../computed/index.mjs';
3
+ import { Object } from '../object/index.mjs';
2
4
  import { Intersect } from '../intersect/index.mjs';
3
5
  import { Union } from '../union/index.mjs';
4
- import { Object } from '../object/index.mjs';
6
+ import { Ref } from '../ref/index.mjs';
5
7
  import { OptionalKind, TransformKind } from '../symbols/index.mjs';
6
8
  import { Discard } from '../discard/index.mjs';
7
9
  import { RequiredFromMappedResult } from './required-from-mapped-result.mjs';
8
10
  // ------------------------------------------------------------------
9
11
  // TypeGuard
10
12
  // ------------------------------------------------------------------
11
- import { IsMappedResult, IsIntersect, IsUnion, IsObject } from '../guard/kind.mjs';
13
+ import { IsMappedResult, IsIntersect, IsUnion, IsObject, IsRef, IsComputed } from '../guard/kind.mjs';
14
+ // prettier-ignore
15
+ function FromComputed(target, parameters) {
16
+ return Computed('Required', [Computed(target, parameters)]);
17
+ }
12
18
  // prettier-ignore
13
- function FromRest(T) {
14
- return T.map(L => RequiredResolve(L));
19
+ function FromRef($ref) {
20
+ return Computed('Required', [Ref($ref)]);
15
21
  }
16
22
  // prettier-ignore
17
- function FromProperties(T) {
18
- const Acc = {};
19
- for (const K of globalThis.Object.getOwnPropertyNames(T))
20
- Acc[K] = Discard(T[K], [OptionalKind]);
21
- return Acc;
23
+ function FromProperties(properties) {
24
+ const requiredProperties = {};
25
+ for (const K of globalThis.Object.getOwnPropertyNames(properties))
26
+ requiredProperties[K] = Discard(properties[K], [OptionalKind]);
27
+ return requiredProperties;
22
28
  }
23
29
  // prettier-ignore
24
- function FromObject(T) {
25
- const options = Discard(T, [TransformKind, '$id', 'required', 'properties']);
26
- const properties = FromProperties(T['properties']);
30
+ function FromObject(type) {
31
+ const options = Discard(type, [TransformKind, '$id', 'required', 'properties']);
32
+ const properties = FromProperties(type['properties']);
27
33
  return Object(properties, options);
28
34
  }
35
+ // prettier-ignore
36
+ function FromRest(types) {
37
+ return types.map(type => RequiredResolve(type));
38
+ }
29
39
  // ------------------------------------------------------------------
30
40
  // RequiredResolve
31
41
  // ------------------------------------------------------------------
32
42
  // prettier-ignore
33
- function RequiredResolve(T) {
34
- return (IsIntersect(T) ? Intersect(FromRest(T.allOf)) :
35
- IsUnion(T) ? Union(FromRest(T.anyOf)) :
36
- IsObject(T) ? FromObject(T) :
37
- Object({}));
43
+ function RequiredResolve(type) {
44
+ return (IsComputed(type) ? FromComputed(type.target, type.parameters) :
45
+ IsRef(type) ? FromRef(type.$ref) :
46
+ IsIntersect(type) ? Intersect(FromRest(type.allOf)) :
47
+ IsUnion(type) ? Union(FromRest(type.anyOf)) :
48
+ IsObject(type) ? FromObject(type) :
49
+ Object({}));
38
50
  }
39
51
  /** `[Json]` Constructs a type where all properties are required */
40
- export function Required(T, options) {
41
- if (IsMappedResult(T)) {
42
- return RequiredFromMappedResult(T, options);
52
+ export function Required(type, options) {
53
+ if (IsMappedResult(type)) {
54
+ return RequiredFromMappedResult(type, options);
43
55
  }
44
56
  else {
45
57
  // special: mapping types require overridable options
46
- return CreateType({ ...RequiredResolve(T), ...options });
58
+ return CreateType({ ...RequiredResolve(type), ...options });
47
59
  }
48
60
  }
@@ -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 {};
@@ -1,9 +1,9 @@
1
1
  import { CreateType } from '../create/type.mjs';
2
2
  import { Kind } from '../symbols/index.mjs';
3
3
  /** `[Json]` Creates a Tuple type */
4
- export function Tuple(items, options) {
4
+ export function Tuple(types, options) {
5
5
  // prettier-ignore
6
- return CreateType(items.length > 0 ?
7
- { [Kind]: 'Tuple', type: 'array', items, additionalItems: false, minItems: items.length, maxItems: items.length } :
8
- { [Kind]: 'Tuple', type: 'array', minItems: items.length, maxItems: items.length }, options);
6
+ return CreateType(types.length > 0 ?
7
+ { [Kind]: 'Tuple', type: 'array', items: types, additionalItems: false, minItems: types.length, maxItems: types.length } :
8
+ { [Kind]: 'Tuple', type: 'array', minItems: types.length, maxItems: types.length }, options);
9
9
  }
@@ -20,33 +20,33 @@ import { type TVoid } from '../void/index.mjs';
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 */
@@ -35,16 +35,16 @@ export class JavaScriptTypeBuilder extends JsonTypeBuilder {
35
35
  return ConstructorParameters(schema, options);
36
36
  }
37
37
  /** `[JavaScript]` Creates a Constructor type */
38
- Constructor(parameters, returns, options) {
39
- return Constructor(parameters, returns, options);
38
+ Constructor(parameters, instanceType, options) {
39
+ return Constructor(parameters, instanceType, options);
40
40
  }
41
41
  /** `[JavaScript]` Creates a Date type */
42
42
  Date(options = {}) {
43
43
  return Date(options);
44
44
  }
45
45
  /** `[JavaScript]` Creates a Function type */
46
- Function(parameters, returns, options) {
47
- return FunctionType(parameters, returns, options);
46
+ Function(parameters, returnType, options) {
47
+ return FunctionType(parameters, returnType, options);
48
48
  }
49
49
  /** `[JavaScript]` Extracts the InstanceType from the given Constructor type */
50
50
  InstanceType(schema, options) {
@@ -67,8 +67,8 @@ export class JavaScriptTypeBuilder extends JsonTypeBuilder {
67
67
  return RegExp(unresolved, options);
68
68
  }
69
69
  /** `[JavaScript]` Extracts the ReturnType from the given Function type */
70
- ReturnType(schema, options) {
71
- return ReturnType(schema, options);
70
+ ReturnType(type, options) {
71
+ return ReturnType(type, options);
72
72
  }
73
73
  /** `[JavaScript]` Creates a Symbol type */
74
74
  Symbol(options) {
@@ -7,11 +7,11 @@ import { type TEnum, type TEnumKey, type TEnumValue } from '../enum/index.mjs';
7
7
  import { type TExclude, type TExcludeFromMappedResult, type TExcludeFromTemplateLiteral } from '../exclude/index.mjs';
8
8
  import { type TExtends, type TExtendsFromMappedKey, type TExtendsFromMappedResult } from '../extends/index.mjs';
9
9
  import { type TExtract, type TExtractFromMappedResult, type TExtractFromTemplateLiteral } from '../extract/index.mjs';
10
- import { TIndex, type TIndexPropertyKeys, type TIndexFromMappedKey, type TIndexFromMappedResult } from '../indexed/index.mjs';
10
+ import { TIndex, type TIndexPropertyKeys } from '../indexed/index.mjs';
11
11
  import { type IntegerOptions, type TInteger } from '../integer/index.mjs';
12
12
  import { Intersect, type IntersectOptions } from '../intersect/index.mjs';
13
13
  import { type TCapitalize, type TUncapitalize, type TLowercase, type TUppercase } from '../intrinsic/index.mjs';
14
- import { type TKeyOf, type TKeyOfFromMappedResult } from '../keyof/index.mjs';
14
+ import { type TKeyOf } from '../keyof/index.mjs';
15
15
  import { type TLiteral, type TLiteralValue } from '../literal/index.mjs';
16
16
  import { type TMappedFunction, type TMapped, type TMappedResult } from '../mapped/index.mjs';
17
17
  import { type TNever } from '../never/index.mjs';
@@ -21,10 +21,10 @@ import { type TMappedKey } from '../mapped/index.mjs';
21
21
  import { TModule } from '../module/index.mjs';
22
22
  import { type TNumber, type NumberOptions } from '../number/index.mjs';
23
23
  import { type TObject, type TProperties, type ObjectOptions } from '../object/index.mjs';
24
- import { type TOmit, type TOmitFromMappedKey, type TOmitFromMappedResult } from '../omit/index.mjs';
24
+ import { type TOmit } from '../omit/index.mjs';
25
25
  import { type TOptionalWithFlag, type TOptionalFromMappedResult } from '../optional/index.mjs';
26
26
  import { type TPartial, type TPartialFromMappedResult } from '../partial/index.mjs';
27
- import { type TPick, type TPickFromMappedKey, type TPickFromMappedResult } from '../pick/index.mjs';
27
+ import { type TPick } from '../pick/index.mjs';
28
28
  import { type TReadonlyWithFlag, type TReadonlyFromMappedResult } from '../readonly/index.mjs';
29
29
  import { type TReadonlyOptional } from '../readonly-optional/index.mjs';
30
30
  import { type TRecordOrObject } from '../record/index.mjs';
@@ -43,27 +43,27 @@ import { type TUnsafe, type UnsafeOptions } from '../unsafe/index.mjs';
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 */
@@ -44,16 +44,16 @@ export class JsonTypeBuilder {
44
44
  // Modifiers
45
45
  // ------------------------------------------------------------------------
46
46
  /** `[Json]` Creates a Readonly and Optional property */
47
- ReadonlyOptional(schema) {
48
- return ReadonlyOptional(schema);
47
+ ReadonlyOptional(type) {
48
+ return ReadonlyOptional(type);
49
49
  }
50
50
  /** `[Json]` Creates a Readonly property */
51
- Readonly(schema, enable) {
52
- return Readonly(schema, enable ?? true);
51
+ Readonly(type, enable) {
52
+ return Readonly(type, enable ?? true);
53
53
  }
54
54
  /** `[Json]` Creates a Optional property */
55
- Optional(schema, enable) {
56
- return Optional(schema, enable ?? true);
55
+ Optional(type, enable) {
56
+ return Optional(type, enable ?? true);
57
57
  }
58
58
  // ------------------------------------------------------------------------
59
59
  // Types
@@ -63,8 +63,8 @@ export class JsonTypeBuilder {
63
63
  return Any(options);
64
64
  }
65
65
  /** `[Json]` Creates an Array type */
66
- Array(schema, options) {
67
- return Array(schema, options);
66
+ Array(items, options) {
67
+ return Array(items, options);
68
68
  }
69
69
  /** `[Json]` Creates a Boolean type */
70
70
  Boolean(options) {
@@ -99,28 +99,28 @@ export class JsonTypeBuilder {
99
99
  return Extract(type, union, options);
100
100
  }
101
101
  /** `[Json]` Returns an Indexed property type for the given keys */
102
- Index(schema, unresolved, options) {
103
- return Index(schema, unresolved, options);
102
+ Index(type, key, options) {
103
+ return Index(type, key, options);
104
104
  }
105
105
  /** `[Json]` Creates an Integer type */
106
106
  Integer(options) {
107
107
  return Integer(options);
108
108
  }
109
109
  /** `[Json]` Creates an Intersect type */
110
- Intersect(T, options) {
111
- return Intersect(T, options);
110
+ Intersect(types, options) {
111
+ return Intersect(types, options);
112
112
  }
113
113
  /** `[Json]` Creates a KeyOf type */
114
- KeyOf(schema, options) {
115
- return KeyOf(schema, options);
114
+ KeyOf(type, options) {
115
+ return KeyOf(type, options);
116
116
  }
117
117
  /** `[Json]` Creates a Literal type */
118
- Literal(value, options) {
119
- return Literal(value, options);
118
+ Literal(literalValue, options) {
119
+ return Literal(literalValue, options);
120
120
  }
121
121
  /** `[Json]` Intrinsic function to Lowercase LiteralString types */
122
- Lowercase(schema, options) {
123
- return Lowercase(schema, options);
122
+ Lowercase(type, options) {
123
+ return Lowercase(type, options);
124
124
  }
125
125
  /** `[Json]` Creates a Mapped object type */
126
126
  Mapped(key, map, options) {
@@ -135,8 +135,8 @@ export class JsonTypeBuilder {
135
135
  return Never(options);
136
136
  }
137
137
  /** `[Json]` Creates a Not type */
138
- Not(schema, options) {
139
- return Not(schema, options);
138
+ Not(type, options) {
139
+ return Not(type, options);
140
140
  }
141
141
  /** `[Json]` Creates a Null type */
142
142
  Null(options) {
@@ -151,20 +151,20 @@ export class JsonTypeBuilder {
151
151
  return Object(properties, options);
152
152
  }
153
153
  /** `[Json]` Constructs a type whose keys are omitted from the given type */
154
- Omit(schema, unresolved, options) {
155
- return Omit(schema, unresolved, options);
154
+ Omit(schema, selector, options) {
155
+ return Omit(schema, selector, options);
156
156
  }
157
157
  /** `[Json]` Constructs a type where all properties are optional */
158
- Partial(schema, options) {
159
- return Partial(schema, options);
158
+ Partial(type, options) {
159
+ return Partial(type, options);
160
160
  }
161
161
  /** `[Json]` Constructs a type whose keys are picked from the given type */
162
- Pick(schema, unresolved, options) {
163
- return Pick(schema, unresolved, options);
162
+ Pick(type, key, options) {
163
+ return Pick(type, key, options);
164
164
  }
165
165
  /** `[Json]` Creates a Record type */
166
- Record(key, schema, options) {
167
- return Record(key, schema, options);
166
+ Record(key, value, options) {
167
+ return Record(key, value, options);
168
168
  }
169
169
  /** `[Json]` Creates a Recursive type */
170
170
  Recursive(callback, options) {
@@ -175,12 +175,12 @@ export class JsonTypeBuilder {
175
175
  return Ref($ref, options);
176
176
  }
177
177
  /** `[Json]` Constructs a type where all properties are required */
178
- Required(schema, options) {
179
- return Required(schema, options);
178
+ Required(type, options) {
179
+ return Required(type, options);
180
180
  }
181
181
  /** `[Json]` Extracts interior Rest elements from Tuple, Intersect and Union types */
182
- Rest(schema) {
183
- return Rest(schema);
182
+ Rest(type) {
183
+ return Rest(type);
184
184
  }
185
185
  /** `[Json]` Creates a String type */
186
186
  String(options) {
@@ -191,20 +191,20 @@ export class JsonTypeBuilder {
191
191
  return TemplateLiteral(unresolved, options);
192
192
  }
193
193
  /** `[Json]` Creates a Transform type */
194
- Transform(schema) {
195
- return Transform(schema);
194
+ Transform(type) {
195
+ return Transform(type);
196
196
  }
197
197
  /** `[Json]` Creates a Tuple type */
198
- Tuple(items, options) {
199
- return Tuple(items, options);
198
+ Tuple(types, options) {
199
+ return Tuple(types, options);
200
200
  }
201
201
  /** `[Json]` Intrinsic function to Uncapitalize LiteralString types */
202
- Uncapitalize(schema, options) {
203
- return Uncapitalize(schema, options);
202
+ Uncapitalize(type, options) {
203
+ return Uncapitalize(type, options);
204
204
  }
205
205
  /** `[Json]` Creates a Union type */
206
- Union(schemas, options) {
207
- return Union(schemas, options);
206
+ Union(types, options) {
207
+ return Union(types, options);
208
208
  }
209
209
  /** `[Json]` Creates an Unknown type */
210
210
  Unknown(options) {
@@ -3,11 +3,11 @@ import { type TNever } from '../never/index.mjs';
3
3
  import { type TOptional } from '../optional/index.mjs';
4
4
  import type { TReadonly } from '../readonly/index.mjs';
5
5
  import type { TUnion } from './union-type.mjs';
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 {};
@@ -9,27 +9,28 @@ import { UnionCreate } from './union-create.mjs';
9
9
  // ------------------------------------------------------------------
10
10
  import { IsOptional } from '../guard/kind.mjs';
11
11
  // prettier-ignore
12
- function IsUnionOptional(T) {
13
- return T.some(L => IsOptional(L));
12
+ function IsUnionOptional(types) {
13
+ return types.some(type => IsOptional(type));
14
14
  }
15
15
  // prettier-ignore
16
- function RemoveOptionalFromRest(T) {
17
- return T.map(L => IsOptional(L) ? RemoveOptionalFromType(L) : L);
16
+ function RemoveOptionalFromRest(types) {
17
+ return types.map(left => IsOptional(left) ? RemoveOptionalFromType(left) : left);
18
18
  }
19
19
  // prettier-ignore
20
20
  function RemoveOptionalFromType(T) {
21
21
  return (Discard(T, [OptionalKind]));
22
22
  }
23
23
  // prettier-ignore
24
- function ResolveUnion(T, options) {
25
- return (IsUnionOptional(T)
26
- ? Optional(UnionCreate(RemoveOptionalFromRest(T), options))
27
- : UnionCreate(RemoveOptionalFromRest(T), options));
24
+ function ResolveUnion(types, options) {
25
+ const isOptional = IsUnionOptional(types);
26
+ return (isOptional
27
+ ? Optional(UnionCreate(RemoveOptionalFromRest(types), options))
28
+ : UnionCreate(RemoveOptionalFromRest(types), options));
28
29
  }
29
30
  /** `[Json]` Creates an evaluated Union type */
30
31
  export function UnionEvaluated(T, options) {
31
32
  // prettier-ignore
32
- return (T.length === 0 ? Never(options) :
33
- T.length === 1 ? CreateType(T[0], options) :
33
+ return (T.length === 1 ? CreateType(T[0], options) :
34
+ T.length === 0 ? Never(options) :
34
35
  ResolveUnion(T, options));
35
36
  }
@@ -3,4 +3,4 @@ import { type TNever } from '../never/index.mjs';
3
3
  import type { TUnion } from './union-type.mjs';
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>;
@@ -2,9 +2,9 @@ import { Never } from '../never/index.mjs';
2
2
  import { CreateType } from '../create/type.mjs';
3
3
  import { UnionCreate } from './union-create.mjs';
4
4
  /** `[Json]` Creates a Union type */
5
- export function Union(T, options) {
5
+ export function Union(types, options) {
6
6
  // prettier-ignore
7
- return (T.length === 0 ? Never(options) :
8
- T.length === 1 ? CreateType(T[0], options) :
9
- UnionCreate(T, options));
7
+ return (types.length === 0 ? Never(options) :
8
+ types.length === 1 ? CreateType(types[0], options) :
9
+ UnionCreate(types, options));
10
10
  }