@sinclair/typebox 0.32.0-dev-18 → 0.32.0-dev-19

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 (78) hide show
  1. package/build/import/compiler/compiler.mjs +14 -8
  2. package/build/import/errors/errors.mjs +15 -11
  3. package/build/import/type/awaited/awaited.mjs +4 -4
  4. package/build/import/type/deref/deref.mjs +12 -12
  5. package/build/import/type/exclude/exclude.mjs +8 -5
  6. package/build/import/type/extends/extends-check.mjs +167 -167
  7. package/build/import/type/extends/extends.mjs +3 -3
  8. package/build/import/type/extract/extract.mjs +5 -5
  9. package/build/import/type/guard/type.d.mts +50 -50
  10. package/build/import/type/guard/type.mjs +136 -136
  11. package/build/import/type/indexed/indexed-property-keys.mjs +7 -7
  12. package/build/import/type/indexed/indexed.mjs +9 -9
  13. package/build/import/type/intersect/intersect-create.mjs +4 -4
  14. package/build/import/type/intersect/intersect-evaluated.mjs +1 -1
  15. package/build/import/type/intersect/intersect.mjs +2 -2
  16. package/build/import/type/intrinsic/intrinsic.mjs +5 -5
  17. package/build/import/type/keyof/keyof-property-keys.mjs +7 -7
  18. package/build/import/type/keyof/keyof.mjs +2 -2
  19. package/build/import/type/mapped/mapped.mjs +16 -16
  20. package/build/import/type/modifiers/modifiers.mjs +3 -3
  21. package/build/import/type/object/object.mjs +3 -3
  22. package/build/import/type/omit/omit.mjs +6 -6
  23. package/build/import/type/partial/partial.mjs +5 -5
  24. package/build/import/type/pick/pick.mjs +6 -6
  25. package/build/import/type/record/record.mjs +7 -7
  26. package/build/import/type/required/required.mjs +5 -5
  27. package/build/import/type/rest/rest.mjs +6 -2
  28. package/build/import/type/template-literal/pattern.mjs +9 -9
  29. package/build/import/type/transform/transform.mjs +1 -1
  30. package/build/import/type/union/union-evaluated.mjs +2 -2
  31. package/build/import/value/check/check.mjs +18 -11
  32. package/build/import/value/clean/clean.mjs +9 -7
  33. package/build/import/value/clone/clone.mjs +7 -4
  34. package/build/import/value/convert/convert.mjs +6 -2
  35. package/build/import/value/default/default.mjs +12 -4
  36. package/build/import/value/transform/decode.mjs +12 -6
  37. package/build/import/value/transform/encode.mjs +12 -6
  38. package/build/import/value/transform/has.mjs +24 -18
  39. package/build/require/compiler/compiler.js +77 -71
  40. package/build/require/errors/errors.js +58 -54
  41. package/build/require/type/awaited/awaited.js +3 -3
  42. package/build/require/type/deref/deref.js +11 -11
  43. package/build/require/type/exclude/exclude.js +7 -4
  44. package/build/require/type/extends/extends-check.js +167 -167
  45. package/build/require/type/extends/extends.js +2 -2
  46. package/build/require/type/extract/extract.js +4 -4
  47. package/build/require/type/guard/type.d.ts +50 -50
  48. package/build/require/type/guard/type.js +184 -184
  49. package/build/require/type/indexed/indexed-property-keys.js +6 -6
  50. package/build/require/type/indexed/indexed.js +9 -9
  51. package/build/require/type/intersect/intersect-create.js +3 -3
  52. package/build/require/type/intersect/intersect-evaluated.js +2 -2
  53. package/build/require/type/intersect/intersect.js +1 -1
  54. package/build/require/type/intrinsic/intrinsic.js +4 -4
  55. package/build/require/type/keyof/keyof-property-keys.js +6 -6
  56. package/build/require/type/keyof/keyof.js +1 -1
  57. package/build/require/type/mapped/mapped.js +15 -15
  58. package/build/require/type/modifiers/modifiers.js +2 -2
  59. package/build/require/type/object/object.js +2 -2
  60. package/build/require/type/omit/omit.js +5 -5
  61. package/build/require/type/partial/partial.js +4 -4
  62. package/build/require/type/pick/pick.js +5 -5
  63. package/build/require/type/record/record.js +6 -6
  64. package/build/require/type/required/required.js +4 -4
  65. package/build/require/type/rest/rest.js +5 -1
  66. package/build/require/type/template-literal/pattern.js +8 -8
  67. package/build/require/type/transform/transform.js +1 -1
  68. package/build/require/type/union/union-evaluated.js +1 -1
  69. package/build/require/value/check/check.js +63 -56
  70. package/build/require/value/clean/clean.js +31 -29
  71. package/build/require/value/clone/clone.js +7 -4
  72. package/build/require/value/convert/convert.js +42 -38
  73. package/build/require/value/default/default.js +24 -16
  74. package/build/require/value/transform/decode.js +27 -21
  75. package/build/require/value/transform/encode.js +28 -22
  76. package/build/require/value/transform/has.js +29 -23
  77. package/package.json +1 -1
  78. package/readme.md +5 -5
@@ -34,19 +34,19 @@ function Throw(message) {
34
34
  // ------------------------------------------------------------------
35
35
  // prettier-ignore
36
36
  function IsStructuralRight(right) {
37
- return (TypeGuard.TNever(right) ||
38
- TypeGuard.TIntersect(right) ||
39
- TypeGuard.TUnion(right) ||
40
- TypeGuard.TUnknown(right) ||
41
- TypeGuard.TAny(right));
37
+ return (TypeGuard.IsNever(right) ||
38
+ TypeGuard.IsIntersect(right) ||
39
+ TypeGuard.IsUnion(right) ||
40
+ TypeGuard.IsUnknown(right) ||
41
+ TypeGuard.IsAny(right));
42
42
  }
43
43
  // prettier-ignore
44
44
  function StructuralRight(left, right) {
45
- return (TypeGuard.TNever(right) ? TNeverRight(left, right) :
46
- TypeGuard.TIntersect(right) ? TIntersectRight(left, right) :
47
- TypeGuard.TUnion(right) ? TUnionRight(left, right) :
48
- TypeGuard.TUnknown(right) ? TUnknownRight(left, right) :
49
- TypeGuard.TAny(right) ? TAnyRight(left, right) :
45
+ return (TypeGuard.IsNever(right) ? TNeverRight(left, right) :
46
+ TypeGuard.IsIntersect(right) ? TIntersectRight(left, right) :
47
+ TypeGuard.IsUnion(right) ? TUnionRight(left, right) :
48
+ TypeGuard.IsUnknown(right) ? TUnknownRight(left, right) :
49
+ TypeGuard.IsAny(right) ? TAnyRight(left, right) :
50
50
  Throw('StructuralRight'));
51
51
  }
52
52
  // ------------------------------------------------------------------
@@ -58,11 +58,11 @@ function TAnyRight(left, right) {
58
58
  }
59
59
  // prettier-ignore
60
60
  function TAny(left, right) {
61
- return (TypeGuard.TIntersect(right) ? TIntersectRight(left, right) :
62
- (TypeGuard.TUnion(right) && right.anyOf.some((schema) => TypeGuard.TAny(schema) || TypeGuard.TUnknown(schema))) ? ExtendsResult.True :
63
- TypeGuard.TUnion(right) ? ExtendsResult.Union :
64
- TypeGuard.TUnknown(right) ? ExtendsResult.True :
65
- TypeGuard.TAny(right) ? ExtendsResult.True :
61
+ return (TypeGuard.IsIntersect(right) ? TIntersectRight(left, right) :
62
+ (TypeGuard.IsUnion(right) && right.anyOf.some((schema) => TypeGuard.IsAny(schema) || TypeGuard.IsUnknown(schema))) ? ExtendsResult.True :
63
+ TypeGuard.IsUnion(right) ? ExtendsResult.Union :
64
+ TypeGuard.IsUnknown(right) ? ExtendsResult.True :
65
+ TypeGuard.IsAny(right) ? ExtendsResult.True :
66
66
  ExtendsResult.Union);
67
67
  }
68
68
  // ------------------------------------------------------------------
@@ -70,16 +70,16 @@ function TAny(left, right) {
70
70
  // ------------------------------------------------------------------
71
71
  // prettier-ignore
72
72
  function TArrayRight(left, right) {
73
- return (TypeGuard.TUnknown(left) ? ExtendsResult.False :
74
- TypeGuard.TAny(left) ? ExtendsResult.Union :
75
- TypeGuard.TNever(left) ? ExtendsResult.True :
73
+ return (TypeGuard.IsUnknown(left) ? ExtendsResult.False :
74
+ TypeGuard.IsAny(left) ? ExtendsResult.Union :
75
+ TypeGuard.IsNever(left) ? ExtendsResult.True :
76
76
  ExtendsResult.False);
77
77
  }
78
78
  // prettier-ignore
79
79
  function TArray(left, right) {
80
- return (TypeGuard.TObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True :
80
+ return (TypeGuard.IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True :
81
81
  IsStructuralRight(right) ? StructuralRight(left, right) :
82
- !TypeGuard.TArray(right) ? ExtendsResult.False :
82
+ !TypeGuard.IsArray(right) ? ExtendsResult.False :
83
83
  IntoBooleanResult(Visit(left.items, right.items)));
84
84
  }
85
85
  // ------------------------------------------------------------------
@@ -88,7 +88,7 @@ function TArray(left, right) {
88
88
  // prettier-ignore
89
89
  function TAsyncIterator(left, right) {
90
90
  return (IsStructuralRight(right) ? StructuralRight(left, right) :
91
- !TypeGuard.TAsyncIterator(right) ? ExtendsResult.False :
91
+ !TypeGuard.IsAsyncIterator(right) ? ExtendsResult.False :
92
92
  IntoBooleanResult(Visit(left.items, right.items)));
93
93
  }
94
94
  // ------------------------------------------------------------------
@@ -97,9 +97,9 @@ function TAsyncIterator(left, right) {
97
97
  // prettier-ignore
98
98
  function TBigInt(left, right) {
99
99
  return (IsStructuralRight(right) ? StructuralRight(left, right) :
100
- TypeGuard.TObject(right) ? TObjectRight(left, right) :
101
- TypeGuard.TRecord(right) ? TRecordRight(left, right) :
102
- TypeGuard.TBigInt(right) ? ExtendsResult.True :
100
+ TypeGuard.IsObject(right) ? TObjectRight(left, right) :
101
+ TypeGuard.IsRecord(right) ? TRecordRight(left, right) :
102
+ TypeGuard.IsBigInt(right) ? ExtendsResult.True :
103
103
  ExtendsResult.False);
104
104
  }
105
105
  // ------------------------------------------------------------------
@@ -107,16 +107,16 @@ function TBigInt(left, right) {
107
107
  // ------------------------------------------------------------------
108
108
  // prettier-ignore
109
109
  function TBooleanRight(left, right) {
110
- return (TypeGuard.TLiteralBoolean(left) ? ExtendsResult.True :
111
- TypeGuard.TBoolean(left) ? ExtendsResult.True :
110
+ return (TypeGuard.IsLiteralBoolean(left) ? ExtendsResult.True :
111
+ TypeGuard.IsBoolean(left) ? ExtendsResult.True :
112
112
  ExtendsResult.False);
113
113
  }
114
114
  // prettier-ignore
115
115
  function TBoolean(left, right) {
116
116
  return (IsStructuralRight(right) ? StructuralRight(left, right) :
117
- TypeGuard.TObject(right) ? TObjectRight(left, right) :
118
- TypeGuard.TRecord(right) ? TRecordRight(left, right) :
119
- TypeGuard.TBoolean(right) ? ExtendsResult.True :
117
+ TypeGuard.IsObject(right) ? TObjectRight(left, right) :
118
+ TypeGuard.IsRecord(right) ? TRecordRight(left, right) :
119
+ TypeGuard.IsBoolean(right) ? ExtendsResult.True :
120
120
  ExtendsResult.False);
121
121
  }
122
122
  // ------------------------------------------------------------------
@@ -125,8 +125,8 @@ function TBoolean(left, right) {
125
125
  // prettier-ignore
126
126
  function TConstructor(left, right) {
127
127
  return (IsStructuralRight(right) ? StructuralRight(left, right) :
128
- TypeGuard.TObject(right) ? TObjectRight(left, right) :
129
- !TypeGuard.TConstructor(right) ? ExtendsResult.False :
128
+ TypeGuard.IsObject(right) ? TObjectRight(left, right) :
129
+ !TypeGuard.IsConstructor(right) ? ExtendsResult.False :
130
130
  left.parameters.length > right.parameters.length ? ExtendsResult.False :
131
131
  (!left.parameters.every((schema, index) => IntoBooleanResult(Visit(right.parameters[index], schema)) === ExtendsResult.True)) ? ExtendsResult.False :
132
132
  IntoBooleanResult(Visit(left.returns, right.returns)));
@@ -137,9 +137,9 @@ function TConstructor(left, right) {
137
137
  // prettier-ignore
138
138
  function TDate(left, right) {
139
139
  return (IsStructuralRight(right) ? StructuralRight(left, right) :
140
- TypeGuard.TObject(right) ? TObjectRight(left, right) :
141
- TypeGuard.TRecord(right) ? TRecordRight(left, right) :
142
- TypeGuard.TDate(right) ? ExtendsResult.True :
140
+ TypeGuard.IsObject(right) ? TObjectRight(left, right) :
141
+ TypeGuard.IsRecord(right) ? TRecordRight(left, right) :
142
+ TypeGuard.IsDate(right) ? ExtendsResult.True :
143
143
  ExtendsResult.False);
144
144
  }
145
145
  // ------------------------------------------------------------------
@@ -148,8 +148,8 @@ function TDate(left, right) {
148
148
  // prettier-ignore
149
149
  function TFunction(left, right) {
150
150
  return (IsStructuralRight(right) ? StructuralRight(left, right) :
151
- TypeGuard.TObject(right) ? TObjectRight(left, right) :
152
- !TypeGuard.TFunction(right) ? ExtendsResult.False :
151
+ TypeGuard.IsObject(right) ? TObjectRight(left, right) :
152
+ !TypeGuard.IsFunction(right) ? ExtendsResult.False :
153
153
  left.parameters.length > right.parameters.length ? ExtendsResult.False :
154
154
  (!left.parameters.every((schema, index) => IntoBooleanResult(Visit(right.parameters[index], schema)) === ExtendsResult.True)) ? ExtendsResult.False :
155
155
  IntoBooleanResult(Visit(left.returns, right.returns)));
@@ -159,16 +159,16 @@ function TFunction(left, right) {
159
159
  // ------------------------------------------------------------------
160
160
  // prettier-ignore
161
161
  function TIntegerRight(left, right) {
162
- return (TypeGuard.TLiteral(left) && ValueGuard.IsNumber(left.const) ? ExtendsResult.True :
163
- TypeGuard.TNumber(left) || TypeGuard.TInteger(left) ? ExtendsResult.True :
162
+ return (TypeGuard.IsLiteral(left) && ValueGuard.IsNumber(left.const) ? ExtendsResult.True :
163
+ TypeGuard.IsNumber(left) || TypeGuard.IsInteger(left) ? ExtendsResult.True :
164
164
  ExtendsResult.False);
165
165
  }
166
166
  // prettier-ignore
167
167
  function TInteger(left, right) {
168
- return (TypeGuard.TInteger(right) || TypeGuard.TNumber(right) ? ExtendsResult.True :
168
+ return (TypeGuard.IsInteger(right) || TypeGuard.IsNumber(right) ? ExtendsResult.True :
169
169
  IsStructuralRight(right) ? StructuralRight(left, right) :
170
- TypeGuard.TObject(right) ? TObjectRight(left, right) :
171
- TypeGuard.TRecord(right) ? TRecordRight(left, right) :
170
+ TypeGuard.IsObject(right) ? TObjectRight(left, right) :
171
+ TypeGuard.IsRecord(right) ? TRecordRight(left, right) :
172
172
  ExtendsResult.False);
173
173
  }
174
174
  // ------------------------------------------------------------------
@@ -192,7 +192,7 @@ function TIntersect(left, right) {
192
192
  // prettier-ignore
193
193
  function TIterator(left, right) {
194
194
  return (IsStructuralRight(right) ? StructuralRight(left, right) :
195
- !TypeGuard.TIterator(right) ? ExtendsResult.False :
195
+ !TypeGuard.IsIterator(right) ? ExtendsResult.False :
196
196
  IntoBooleanResult(Visit(left.items, right.items)));
197
197
  }
198
198
  // ------------------------------------------------------------------
@@ -200,14 +200,14 @@ function TIterator(left, right) {
200
200
  // ------------------------------------------------------------------
201
201
  // prettier-ignore
202
202
  function TLiteral(left, right) {
203
- return (TypeGuard.TLiteral(right) && right.const === left.const ? ExtendsResult.True :
203
+ return (TypeGuard.IsLiteral(right) && right.const === left.const ? ExtendsResult.True :
204
204
  IsStructuralRight(right) ? StructuralRight(left, right) :
205
- TypeGuard.TObject(right) ? TObjectRight(left, right) :
206
- TypeGuard.TRecord(right) ? TRecordRight(left, right) :
207
- TypeGuard.TString(right) ? TStringRight(left, right) :
208
- TypeGuard.TNumber(right) ? TNumberRight(left, right) :
209
- TypeGuard.TInteger(right) ? TIntegerRight(left, right) :
210
- TypeGuard.TBoolean(right) ? TBooleanRight(left, right) :
205
+ TypeGuard.IsObject(right) ? TObjectRight(left, right) :
206
+ TypeGuard.IsRecord(right) ? TRecordRight(left, right) :
207
+ TypeGuard.IsString(right) ? TStringRight(left, right) :
208
+ TypeGuard.IsNumber(right) ? TNumberRight(left, right) :
209
+ TypeGuard.IsInteger(right) ? TIntegerRight(left, right) :
210
+ TypeGuard.IsBoolean(right) ? TBooleanRight(left, right) :
211
211
  ExtendsResult.False);
212
212
  }
213
213
  // ------------------------------------------------------------------
@@ -228,7 +228,7 @@ function TNever(left, right) {
228
228
  function UnwrapTNot(schema) {
229
229
  let [current, depth] = [schema, 0];
230
230
  while (true) {
231
- if (!TypeGuard.TNot(current))
231
+ if (!TypeGuard.IsNot(current))
232
232
  break;
233
233
  current = current.not;
234
234
  depth += 1;
@@ -241,8 +241,8 @@ function TNot(left, right) {
241
241
  // type at runtime would put TypeBox at odds with TypeScripts ability to statically infer
242
242
  // the type. Instead we unwrap to either unknown or T and continue evaluating.
243
243
  // prettier-ignore
244
- return (TypeGuard.TNot(left) ? Visit(UnwrapTNot(left), right) :
245
- TypeGuard.TNot(right) ? Visit(left, UnwrapTNot(right)) :
244
+ return (TypeGuard.IsNot(left) ? Visit(UnwrapTNot(left), right) :
245
+ TypeGuard.IsNot(right) ? Visit(left, UnwrapTNot(right)) :
246
246
  Throw('Invalid fallthrough for Not'));
247
247
  }
248
248
  // ------------------------------------------------------------------
@@ -251,9 +251,9 @@ function TNot(left, right) {
251
251
  // prettier-ignore
252
252
  function TNull(left, right) {
253
253
  return (IsStructuralRight(right) ? StructuralRight(left, right) :
254
- TypeGuard.TObject(right) ? TObjectRight(left, right) :
255
- TypeGuard.TRecord(right) ? TRecordRight(left, right) :
256
- TypeGuard.TNull(right) ? ExtendsResult.True :
254
+ TypeGuard.IsObject(right) ? TObjectRight(left, right) :
255
+ TypeGuard.IsRecord(right) ? TRecordRight(left, right) :
256
+ TypeGuard.IsNull(right) ? ExtendsResult.True :
257
257
  ExtendsResult.False);
258
258
  }
259
259
  // ------------------------------------------------------------------
@@ -261,16 +261,16 @@ function TNull(left, right) {
261
261
  // ------------------------------------------------------------------
262
262
  // prettier-ignore
263
263
  function TNumberRight(left, right) {
264
- return (TypeGuard.TLiteralNumber(left) ? ExtendsResult.True :
265
- TypeGuard.TNumber(left) || TypeGuard.TInteger(left) ? ExtendsResult.True :
264
+ return (TypeGuard.IsLiteralNumber(left) ? ExtendsResult.True :
265
+ TypeGuard.IsNumber(left) || TypeGuard.IsInteger(left) ? ExtendsResult.True :
266
266
  ExtendsResult.False);
267
267
  }
268
268
  // prettier-ignore
269
269
  function TNumber(left, right) {
270
270
  return (IsStructuralRight(right) ? StructuralRight(left, right) :
271
- TypeGuard.TObject(right) ? TObjectRight(left, right) :
272
- TypeGuard.TRecord(right) ? TRecordRight(left, right) :
273
- TypeGuard.TInteger(right) || TypeGuard.TNumber(right) ? ExtendsResult.True :
271
+ TypeGuard.IsObject(right) ? TObjectRight(left, right) :
272
+ TypeGuard.IsRecord(right) ? TRecordRight(left, right) :
273
+ TypeGuard.IsInteger(right) || TypeGuard.IsNumber(right) ? ExtendsResult.True :
274
274
  ExtendsResult.False);
275
275
  }
276
276
  // ------------------------------------------------------------------
@@ -286,9 +286,9 @@ function IsObjectStringLike(schema) {
286
286
  }
287
287
  // prettier-ignore
288
288
  function IsObjectSymbolLike(schema) {
289
- return IsObjectPropertyCount(schema, 0) || (IsObjectPropertyCount(schema, 1) && 'description' in schema.properties && TypeGuard.TUnion(schema.properties.description) && schema.properties.description.anyOf.length === 2 && ((TypeGuard.TString(schema.properties.description.anyOf[0]) &&
290
- TypeGuard.TUndefined(schema.properties.description.anyOf[1])) || (TypeGuard.TString(schema.properties.description.anyOf[1]) &&
291
- TypeGuard.TUndefined(schema.properties.description.anyOf[0]))));
289
+ return IsObjectPropertyCount(schema, 0) || (IsObjectPropertyCount(schema, 1) && 'description' in schema.properties && TypeGuard.IsUnion(schema.properties.description) && schema.properties.description.anyOf.length === 2 && ((TypeGuard.IsString(schema.properties.description.anyOf[0]) &&
290
+ TypeGuard.IsUndefined(schema.properties.description.anyOf[1])) || (TypeGuard.IsString(schema.properties.description.anyOf[1]) &&
291
+ TypeGuard.IsUndefined(schema.properties.description.anyOf[0]))));
292
292
  }
293
293
  // prettier-ignore
294
294
  function IsObjectNumberLike(schema) {
@@ -335,33 +335,33 @@ function IsObjectPromiseLike(schema) {
335
335
  // prettier-ignore
336
336
  function Property(left, right) {
337
337
  return (Visit(left, right) === ExtendsResult.False ? ExtendsResult.False :
338
- TypeGuard.TOptional(left) && !TypeGuard.TOptional(right) ? ExtendsResult.False :
338
+ TypeGuard.IsOptional(left) && !TypeGuard.IsOptional(right) ? ExtendsResult.False :
339
339
  ExtendsResult.True);
340
340
  }
341
341
  // prettier-ignore
342
342
  function TObjectRight(left, right) {
343
- return (TypeGuard.TUnknown(left) ? ExtendsResult.False :
344
- TypeGuard.TAny(left) ? ExtendsResult.Union : (TypeGuard.TNever(left) ||
345
- (TypeGuard.TLiteralString(left) && IsObjectStringLike(right)) ||
346
- (TypeGuard.TLiteralNumber(left) && IsObjectNumberLike(right)) ||
347
- (TypeGuard.TLiteralBoolean(left) && IsObjectBooleanLike(right)) ||
348
- (TypeGuard.TSymbol(left) && IsObjectSymbolLike(right)) ||
349
- (TypeGuard.TBigInt(left) && IsObjectBigIntLike(right)) ||
350
- (TypeGuard.TString(left) && IsObjectStringLike(right)) ||
351
- (TypeGuard.TSymbol(left) && IsObjectSymbolLike(right)) ||
352
- (TypeGuard.TNumber(left) && IsObjectNumberLike(right)) ||
353
- (TypeGuard.TInteger(left) && IsObjectNumberLike(right)) ||
354
- (TypeGuard.TBoolean(left) && IsObjectBooleanLike(right)) ||
355
- (TypeGuard.TUint8Array(left) && IsObjectUint8ArrayLike(right)) ||
356
- (TypeGuard.TDate(left) && IsObjectDateLike(right)) ||
357
- (TypeGuard.TConstructor(left) && IsObjectConstructorLike(right)) ||
358
- (TypeGuard.TFunction(left) && IsObjectFunctionLike(right))) ? ExtendsResult.True :
359
- (TypeGuard.TRecord(left) && TypeGuard.TString(RecordKey(left))) ? (() => {
343
+ return (TypeGuard.IsUnknown(left) ? ExtendsResult.False :
344
+ TypeGuard.IsAny(left) ? ExtendsResult.Union : (TypeGuard.IsNever(left) ||
345
+ (TypeGuard.IsLiteralString(left) && IsObjectStringLike(right)) ||
346
+ (TypeGuard.IsLiteralNumber(left) && IsObjectNumberLike(right)) ||
347
+ (TypeGuard.IsLiteralBoolean(left) && IsObjectBooleanLike(right)) ||
348
+ (TypeGuard.IsSymbol(left) && IsObjectSymbolLike(right)) ||
349
+ (TypeGuard.IsBigInt(left) && IsObjectBigIntLike(right)) ||
350
+ (TypeGuard.IsString(left) && IsObjectStringLike(right)) ||
351
+ (TypeGuard.IsSymbol(left) && IsObjectSymbolLike(right)) ||
352
+ (TypeGuard.IsNumber(left) && IsObjectNumberLike(right)) ||
353
+ (TypeGuard.IsInteger(left) && IsObjectNumberLike(right)) ||
354
+ (TypeGuard.IsBoolean(left) && IsObjectBooleanLike(right)) ||
355
+ (TypeGuard.IsUint8Array(left) && IsObjectUint8ArrayLike(right)) ||
356
+ (TypeGuard.IsDate(left) && IsObjectDateLike(right)) ||
357
+ (TypeGuard.IsConstructor(left) && IsObjectConstructorLike(right)) ||
358
+ (TypeGuard.IsFunction(left) && IsObjectFunctionLike(right))) ? ExtendsResult.True :
359
+ (TypeGuard.IsRecord(left) && TypeGuard.IsString(RecordKey(left))) ? (() => {
360
360
  // When expressing a Record with literal key values, the Record is converted into a Object with
361
361
  // the Hint assigned as `Record`. This is used to invert the extends logic.
362
362
  return right[Hint] === 'Record' ? ExtendsResult.True : ExtendsResult.False;
363
363
  })() :
364
- (TypeGuard.TRecord(left) && TypeGuard.TNumber(RecordKey(left))) ? (() => {
364
+ (TypeGuard.IsRecord(left) && TypeGuard.IsNumber(RecordKey(left))) ? (() => {
365
365
  return IsObjectPropertyCount(right, 0) ? ExtendsResult.True : ExtendsResult.False;
366
366
  })() :
367
367
  ExtendsResult.False);
@@ -369,14 +369,14 @@ function TObjectRight(left, right) {
369
369
  // prettier-ignore
370
370
  function TObject(left, right) {
371
371
  return (IsStructuralRight(right) ? StructuralRight(left, right) :
372
- TypeGuard.TRecord(right) ? TRecordRight(left, right) :
373
- !TypeGuard.TObject(right) ? ExtendsResult.False :
372
+ TypeGuard.IsRecord(right) ? TRecordRight(left, right) :
373
+ !TypeGuard.IsObject(right) ? ExtendsResult.False :
374
374
  (() => {
375
375
  for (const key of Object.getOwnPropertyNames(right.properties)) {
376
- if (!(key in left.properties) && !TypeGuard.TOptional(right.properties[key])) {
376
+ if (!(key in left.properties) && !TypeGuard.IsOptional(right.properties[key])) {
377
377
  return ExtendsResult.False;
378
378
  }
379
- if (TypeGuard.TOptional(right.properties[key])) {
379
+ if (TypeGuard.IsOptional(right.properties[key])) {
380
380
  return ExtendsResult.True;
381
381
  }
382
382
  if (Property(left.properties[key], right.properties[key]) === ExtendsResult.False) {
@@ -392,8 +392,8 @@ function TObject(left, right) {
392
392
  // prettier-ignore
393
393
  function TPromise(left, right) {
394
394
  return (IsStructuralRight(right) ? StructuralRight(left, right) :
395
- TypeGuard.TObject(right) && IsObjectPromiseLike(right) ? ExtendsResult.True :
396
- !TypeGuard.TPromise(right) ? ExtendsResult.False :
395
+ TypeGuard.IsObject(right) && IsObjectPromiseLike(right) ? ExtendsResult.True :
396
+ !TypeGuard.IsPromise(right) ? ExtendsResult.False :
397
397
  IntoBooleanResult(Visit(left.item, right.item)));
398
398
  }
399
399
  // ------------------------------------------------------------------
@@ -414,11 +414,11 @@ function RecordValue(schema) {
414
414
  // prettier-ignore
415
415
  function TRecordRight(left, right) {
416
416
  const [Key, Value] = [RecordKey(right), RecordValue(right)];
417
- return ((TypeGuard.TLiteralString(left) && TypeGuard.TNumber(Key) && IntoBooleanResult(Visit(left, Value)) === ExtendsResult.True) ? ExtendsResult.True :
418
- TypeGuard.TUint8Array(left) && TypeGuard.TNumber(Key) ? Visit(left, Value) :
419
- TypeGuard.TString(left) && TypeGuard.TNumber(Key) ? Visit(left, Value) :
420
- TypeGuard.TArray(left) && TypeGuard.TNumber(Key) ? Visit(left, Value) :
421
- TypeGuard.TObject(left) ? (() => {
417
+ return ((TypeGuard.IsLiteralString(left) && TypeGuard.IsNumber(Key) && IntoBooleanResult(Visit(left, Value)) === ExtendsResult.True) ? ExtendsResult.True :
418
+ TypeGuard.IsUint8Array(left) && TypeGuard.IsNumber(Key) ? Visit(left, Value) :
419
+ TypeGuard.IsString(left) && TypeGuard.IsNumber(Key) ? Visit(left, Value) :
420
+ TypeGuard.IsArray(left) && TypeGuard.IsNumber(Key) ? Visit(left, Value) :
421
+ TypeGuard.IsObject(left) ? (() => {
422
422
  for (const key of Object.getOwnPropertyNames(left.properties)) {
423
423
  if (Property(Value, left.properties[key]) === ExtendsResult.False) {
424
424
  return ExtendsResult.False;
@@ -431,8 +431,8 @@ function TRecordRight(left, right) {
431
431
  // prettier-ignore
432
432
  function TRecord(left, right) {
433
433
  return (IsStructuralRight(right) ? StructuralRight(left, right) :
434
- TypeGuard.TObject(right) ? TObjectRight(left, right) :
435
- !TypeGuard.TRecord(right) ? ExtendsResult.False :
434
+ TypeGuard.IsObject(right) ? TObjectRight(left, right) :
435
+ !TypeGuard.IsRecord(right) ? ExtendsResult.False :
436
436
  Visit(RecordValue(left), RecordValue(right)));
437
437
  }
438
438
  // ------------------------------------------------------------------
@@ -440,16 +440,16 @@ function TRecord(left, right) {
440
440
  // ------------------------------------------------------------------
441
441
  // prettier-ignore
442
442
  function TStringRight(left, right) {
443
- return (TypeGuard.TLiteral(left) && ValueGuard.IsString(left.const) ? ExtendsResult.True :
444
- TypeGuard.TString(left) ? ExtendsResult.True :
443
+ return (TypeGuard.IsLiteral(left) && ValueGuard.IsString(left.const) ? ExtendsResult.True :
444
+ TypeGuard.IsString(left) ? ExtendsResult.True :
445
445
  ExtendsResult.False);
446
446
  }
447
447
  // prettier-ignore
448
448
  function TString(left, right) {
449
449
  return (IsStructuralRight(right) ? StructuralRight(left, right) :
450
- TypeGuard.TObject(right) ? TObjectRight(left, right) :
451
- TypeGuard.TRecord(right) ? TRecordRight(left, right) :
452
- TypeGuard.TString(right) ? ExtendsResult.True :
450
+ TypeGuard.IsObject(right) ? TObjectRight(left, right) :
451
+ TypeGuard.IsRecord(right) ? TRecordRight(left, right) :
452
+ TypeGuard.IsString(right) ? ExtendsResult.True :
453
453
  ExtendsResult.False);
454
454
  }
455
455
  // ------------------------------------------------------------------
@@ -458,9 +458,9 @@ function TString(left, right) {
458
458
  // prettier-ignore
459
459
  function TSymbol(left, right) {
460
460
  return (IsStructuralRight(right) ? StructuralRight(left, right) :
461
- TypeGuard.TObject(right) ? TObjectRight(left, right) :
462
- TypeGuard.TRecord(right) ? TRecordRight(left, right) :
463
- TypeGuard.TSymbol(right) ? ExtendsResult.True :
461
+ TypeGuard.IsObject(right) ? TObjectRight(left, right) :
462
+ TypeGuard.IsRecord(right) ? TRecordRight(left, right) :
463
+ TypeGuard.IsSymbol(right) ? ExtendsResult.True :
464
464
  ExtendsResult.False);
465
465
  }
466
466
  // ------------------------------------------------------------------
@@ -471,8 +471,8 @@ function TTemplateLiteral(left, right) {
471
471
  // TemplateLiteral types are resolved to either unions for finite expressions or string
472
472
  // for infinite expressions. Here we call to TemplateLiteralResolver to resolve for
473
473
  // either type and continue evaluating.
474
- return (TypeGuard.TTemplateLiteral(left) ? Visit(TemplateLiteralToUnion(left), right) :
475
- TypeGuard.TTemplateLiteral(right) ? Visit(left, TemplateLiteralToUnion(right)) :
474
+ return (TypeGuard.IsTemplateLiteral(left) ? Visit(TemplateLiteralToUnion(left), right) :
475
+ TypeGuard.IsTemplateLiteral(right) ? Visit(left, TemplateLiteralToUnion(right)) :
476
476
  Throw('Invalid fallthrough for TemplateLiteral'));
477
477
  }
478
478
  // ------------------------------------------------------------------
@@ -480,23 +480,23 @@ function TTemplateLiteral(left, right) {
480
480
  // ------------------------------------------------------------------
481
481
  // prettier-ignore
482
482
  function IsArrayOfTuple(left, right) {
483
- return (TypeGuard.TArray(right) &&
483
+ return (TypeGuard.IsArray(right) &&
484
484
  left.items !== undefined &&
485
485
  left.items.every((schema) => Visit(schema, right.items) === ExtendsResult.True));
486
486
  }
487
487
  // prettier-ignore
488
488
  function TTupleRight(left, right) {
489
- return (TypeGuard.TNever(left) ? ExtendsResult.True :
490
- TypeGuard.TUnknown(left) ? ExtendsResult.False :
491
- TypeGuard.TAny(left) ? ExtendsResult.Union :
489
+ return (TypeGuard.IsNever(left) ? ExtendsResult.True :
490
+ TypeGuard.IsUnknown(left) ? ExtendsResult.False :
491
+ TypeGuard.IsAny(left) ? ExtendsResult.Union :
492
492
  ExtendsResult.False);
493
493
  }
494
494
  // prettier-ignore
495
495
  function TTuple(left, right) {
496
496
  return (IsStructuralRight(right) ? StructuralRight(left, right) :
497
- TypeGuard.TObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True :
498
- TypeGuard.TArray(right) && IsArrayOfTuple(left, right) ? ExtendsResult.True :
499
- !TypeGuard.TTuple(right) ? ExtendsResult.False :
497
+ TypeGuard.IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True :
498
+ TypeGuard.IsArray(right) && IsArrayOfTuple(left, right) ? ExtendsResult.True :
499
+ !TypeGuard.IsTuple(right) ? ExtendsResult.False :
500
500
  (ValueGuard.IsUndefined(left.items) && !ValueGuard.IsUndefined(right.items)) || (!ValueGuard.IsUndefined(left.items) && ValueGuard.IsUndefined(right.items)) ? ExtendsResult.False :
501
501
  (ValueGuard.IsUndefined(left.items) && !ValueGuard.IsUndefined(right.items)) ? ExtendsResult.True :
502
502
  left.items.every((schema, index) => Visit(schema, right.items[index]) === ExtendsResult.True) ? ExtendsResult.True :
@@ -508,9 +508,9 @@ function TTuple(left, right) {
508
508
  // prettier-ignore
509
509
  function TUint8Array(left, right) {
510
510
  return (IsStructuralRight(right) ? StructuralRight(left, right) :
511
- TypeGuard.TObject(right) ? TObjectRight(left, right) :
512
- TypeGuard.TRecord(right) ? TRecordRight(left, right) :
513
- TypeGuard.TUint8Array(right) ? ExtendsResult.True :
511
+ TypeGuard.IsObject(right) ? TObjectRight(left, right) :
512
+ TypeGuard.IsRecord(right) ? TRecordRight(left, right) :
513
+ TypeGuard.IsUint8Array(right) ? ExtendsResult.True :
514
514
  ExtendsResult.False);
515
515
  }
516
516
  // ------------------------------------------------------------------
@@ -519,10 +519,10 @@ function TUint8Array(left, right) {
519
519
  // prettier-ignore
520
520
  function TUndefined(left, right) {
521
521
  return (IsStructuralRight(right) ? StructuralRight(left, right) :
522
- TypeGuard.TObject(right) ? TObjectRight(left, right) :
523
- TypeGuard.TRecord(right) ? TRecordRight(left, right) :
524
- TypeGuard.TVoid(right) ? VoidRight(left, right) :
525
- TypeGuard.TUndefined(right) ? ExtendsResult.True :
522
+ TypeGuard.IsObject(right) ? TObjectRight(left, right) :
523
+ TypeGuard.IsRecord(right) ? TRecordRight(left, right) :
524
+ TypeGuard.IsVoid(right) ? VoidRight(left, right) :
525
+ TypeGuard.IsUndefined(right) ? ExtendsResult.True :
526
526
  ExtendsResult.False);
527
527
  }
528
528
  // ------------------------------------------------------------------
@@ -549,18 +549,18 @@ function TUnknownRight(left, right) {
549
549
  }
550
550
  // prettier-ignore
551
551
  function TUnknown(left, right) {
552
- return (TypeGuard.TNever(right) ? TNeverRight(left, right) :
553
- TypeGuard.TIntersect(right) ? TIntersectRight(left, right) :
554
- TypeGuard.TUnion(right) ? TUnionRight(left, right) :
555
- TypeGuard.TAny(right) ? TAnyRight(left, right) :
556
- TypeGuard.TString(right) ? TStringRight(left, right) :
557
- TypeGuard.TNumber(right) ? TNumberRight(left, right) :
558
- TypeGuard.TInteger(right) ? TIntegerRight(left, right) :
559
- TypeGuard.TBoolean(right) ? TBooleanRight(left, right) :
560
- TypeGuard.TArray(right) ? TArrayRight(left, right) :
561
- TypeGuard.TTuple(right) ? TTupleRight(left, right) :
562
- TypeGuard.TObject(right) ? TObjectRight(left, right) :
563
- TypeGuard.TUnknown(right) ? ExtendsResult.True :
552
+ return (TypeGuard.IsNever(right) ? TNeverRight(left, right) :
553
+ TypeGuard.IsIntersect(right) ? TIntersectRight(left, right) :
554
+ TypeGuard.IsUnion(right) ? TUnionRight(left, right) :
555
+ TypeGuard.IsAny(right) ? TAnyRight(left, right) :
556
+ TypeGuard.IsString(right) ? TStringRight(left, right) :
557
+ TypeGuard.IsNumber(right) ? TNumberRight(left, right) :
558
+ TypeGuard.IsInteger(right) ? TIntegerRight(left, right) :
559
+ TypeGuard.IsBoolean(right) ? TBooleanRight(left, right) :
560
+ TypeGuard.IsArray(right) ? TArrayRight(left, right) :
561
+ TypeGuard.IsTuple(right) ? TTupleRight(left, right) :
562
+ TypeGuard.IsObject(right) ? TObjectRight(left, right) :
563
+ TypeGuard.IsUnknown(right) ? ExtendsResult.True :
564
564
  ExtendsResult.False);
565
565
  }
566
566
  // ------------------------------------------------------------------
@@ -568,53 +568,53 @@ function TUnknown(left, right) {
568
568
  // ------------------------------------------------------------------
569
569
  // prettier-ignore
570
570
  function VoidRight(left, right) {
571
- return (TypeGuard.TUndefined(left) ? ExtendsResult.True :
572
- TypeGuard.TUndefined(left) ? ExtendsResult.True :
571
+ return (TypeGuard.IsUndefined(left) ? ExtendsResult.True :
572
+ TypeGuard.IsUndefined(left) ? ExtendsResult.True :
573
573
  ExtendsResult.False);
574
574
  }
575
575
  // prettier-ignore
576
576
  function TVoid(left, right) {
577
- return (TypeGuard.TIntersect(right) ? TIntersectRight(left, right) :
578
- TypeGuard.TUnion(right) ? TUnionRight(left, right) :
579
- TypeGuard.TUnknown(right) ? TUnknownRight(left, right) :
580
- TypeGuard.TAny(right) ? TAnyRight(left, right) :
581
- TypeGuard.TObject(right) ? TObjectRight(left, right) :
582
- TypeGuard.TVoid(right) ? ExtendsResult.True :
577
+ return (TypeGuard.IsIntersect(right) ? TIntersectRight(left, right) :
578
+ TypeGuard.IsUnion(right) ? TUnionRight(left, right) :
579
+ TypeGuard.IsUnknown(right) ? TUnknownRight(left, right) :
580
+ TypeGuard.IsAny(right) ? TAnyRight(left, right) :
581
+ TypeGuard.IsObject(right) ? TObjectRight(left, right) :
582
+ TypeGuard.IsVoid(right) ? ExtendsResult.True :
583
583
  ExtendsResult.False);
584
584
  }
585
585
  // prettier-ignore
586
586
  function Visit(left, right) {
587
587
  return (
588
588
  // resolvable
589
- (TypeGuard.TTemplateLiteral(left) || TypeGuard.TTemplateLiteral(right)) ? TTemplateLiteral(left, right) :
590
- (TypeGuard.TNot(left) || TypeGuard.TNot(right)) ? TNot(left, right) :
589
+ (TypeGuard.IsTemplateLiteral(left) || TypeGuard.IsTemplateLiteral(right)) ? TTemplateLiteral(left, right) :
590
+ (TypeGuard.IsNot(left) || TypeGuard.IsNot(right)) ? TNot(left, right) :
591
591
  // standard
592
- TypeGuard.TAny(left) ? TAny(left, right) :
593
- TypeGuard.TArray(left) ? TArray(left, right) :
594
- TypeGuard.TBigInt(left) ? TBigInt(left, right) :
595
- TypeGuard.TBoolean(left) ? TBoolean(left, right) :
596
- TypeGuard.TAsyncIterator(left) ? TAsyncIterator(left, right) :
597
- TypeGuard.TConstructor(left) ? TConstructor(left, right) :
598
- TypeGuard.TDate(left) ? TDate(left, right) :
599
- TypeGuard.TFunction(left) ? TFunction(left, right) :
600
- TypeGuard.TInteger(left) ? TInteger(left, right) :
601
- TypeGuard.TIntersect(left) ? TIntersect(left, right) :
602
- TypeGuard.TIterator(left) ? TIterator(left, right) :
603
- TypeGuard.TLiteral(left) ? TLiteral(left, right) :
604
- TypeGuard.TNever(left) ? TNever(left, right) :
605
- TypeGuard.TNull(left) ? TNull(left, right) :
606
- TypeGuard.TNumber(left) ? TNumber(left, right) :
607
- TypeGuard.TObject(left) ? TObject(left, right) :
608
- TypeGuard.TRecord(left) ? TRecord(left, right) :
609
- TypeGuard.TString(left) ? TString(left, right) :
610
- TypeGuard.TSymbol(left) ? TSymbol(left, right) :
611
- TypeGuard.TTuple(left) ? TTuple(left, right) :
612
- TypeGuard.TPromise(left) ? TPromise(left, right) :
613
- TypeGuard.TUint8Array(left) ? TUint8Array(left, right) :
614
- TypeGuard.TUndefined(left) ? TUndefined(left, right) :
615
- TypeGuard.TUnion(left) ? TUnion(left, right) :
616
- TypeGuard.TUnknown(left) ? TUnknown(left, right) :
617
- TypeGuard.TVoid(left) ? TVoid(left, right) :
592
+ TypeGuard.IsAny(left) ? TAny(left, right) :
593
+ TypeGuard.IsArray(left) ? TArray(left, right) :
594
+ TypeGuard.IsBigInt(left) ? TBigInt(left, right) :
595
+ TypeGuard.IsBoolean(left) ? TBoolean(left, right) :
596
+ TypeGuard.IsAsyncIterator(left) ? TAsyncIterator(left, right) :
597
+ TypeGuard.IsConstructor(left) ? TConstructor(left, right) :
598
+ TypeGuard.IsDate(left) ? TDate(left, right) :
599
+ TypeGuard.IsFunction(left) ? TFunction(left, right) :
600
+ TypeGuard.IsInteger(left) ? TInteger(left, right) :
601
+ TypeGuard.IsIntersect(left) ? TIntersect(left, right) :
602
+ TypeGuard.IsIterator(left) ? TIterator(left, right) :
603
+ TypeGuard.IsLiteral(left) ? TLiteral(left, right) :
604
+ TypeGuard.IsNever(left) ? TNever(left, right) :
605
+ TypeGuard.IsNull(left) ? TNull(left, right) :
606
+ TypeGuard.IsNumber(left) ? TNumber(left, right) :
607
+ TypeGuard.IsObject(left) ? TObject(left, right) :
608
+ TypeGuard.IsRecord(left) ? TRecord(left, right) :
609
+ TypeGuard.IsString(left) ? TString(left, right) :
610
+ TypeGuard.IsSymbol(left) ? TSymbol(left, right) :
611
+ TypeGuard.IsTuple(left) ? TTuple(left, right) :
612
+ TypeGuard.IsPromise(left) ? TPromise(left, right) :
613
+ TypeGuard.IsUint8Array(left) ? TUint8Array(left, right) :
614
+ TypeGuard.IsUndefined(left) ? TUndefined(left, right) :
615
+ TypeGuard.IsUnion(left) ? TUnion(left, right) :
616
+ TypeGuard.IsUnknown(left) ? TUnknown(left, right) :
617
+ TypeGuard.IsVoid(left) ? TVoid(left, right) :
618
618
  Throw(`Unknown left type operand '${left[Kind]}'`));
619
619
  }
620
620
  export function ExtendsCheck(left, right) {
@@ -7,7 +7,7 @@ import { ExtendsFromMappedResult } from './extends-from-mapped-result.mjs';
7
7
  // TypeGuard
8
8
  // ------------------------------------------------------------------
9
9
  // prettier-ignore
10
- import { TMappedKey as IsMappedKeyType, TMappedResult as IsMappedResultType } from '../guard/type.mjs';
10
+ import { IsMappedKey, IsMappedResult } from '../guard/type.mjs';
11
11
  // prettier-ignore
12
12
  function ExtendsResolve(left, right, trueType, falseType) {
13
13
  const R = ExtendsCheck(left, right);
@@ -18,7 +18,7 @@ function ExtendsResolve(left, right, trueType, falseType) {
18
18
  /** `[Json]` Creates a Conditional type */
19
19
  export function Extends(L, R, T, F, options = {}) {
20
20
  // prettier-ignore
21
- return (IsMappedResultType(L) ? ExtendsFromMappedResult(L, R, T, F, options) :
22
- IsMappedKeyType(L) ? CloneType(ExtendsFromMappedKey(L, R, T, F, options)) :
21
+ return (IsMappedResult(L) ? ExtendsFromMappedResult(L, R, T, F, options) :
22
+ IsMappedKey(L) ? CloneType(ExtendsFromMappedKey(L, R, T, F, options)) :
23
23
  CloneType(ExtendsResolve(L, R, T, F), options));
24
24
  }