@sinclair/typebox 0.31.20 → 0.31.21
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.
- package/package.json +1 -1
- package/typebox.js +41 -34
package/package.json
CHANGED
package/typebox.js
CHANGED
|
@@ -224,6 +224,9 @@ var TypeGuard;
|
|
|
224
224
|
function IsOptionalSchema(value) {
|
|
225
225
|
return ValueGuard.IsUndefined(value) || TSchema(value);
|
|
226
226
|
}
|
|
227
|
+
// ----------------------------------------------------------------
|
|
228
|
+
// Types
|
|
229
|
+
// ----------------------------------------------------------------
|
|
227
230
|
/** Returns true if the given value is TAny */
|
|
228
231
|
function TAny(schema) {
|
|
229
232
|
// prettier-ignore
|
|
@@ -587,39 +590,39 @@ var TypeGuard;
|
|
|
587
590
|
TypeGuard.TOptional = TOptional;
|
|
588
591
|
/** Returns true if the given value is TSchema */
|
|
589
592
|
function TSchema(schema) {
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
593
|
+
// prettier-ignore
|
|
594
|
+
return (ValueGuard.IsObject(schema)) && (TAny(schema) ||
|
|
595
|
+
TArray(schema) ||
|
|
596
|
+
TBoolean(schema) ||
|
|
597
|
+
TBigInt(schema) ||
|
|
598
|
+
TAsyncIterator(schema) ||
|
|
599
|
+
TConstructor(schema) ||
|
|
600
|
+
TDate(schema) ||
|
|
601
|
+
TFunction(schema) ||
|
|
602
|
+
TInteger(schema) ||
|
|
603
|
+
TIntersect(schema) ||
|
|
604
|
+
TIterator(schema) ||
|
|
605
|
+
TLiteral(schema) ||
|
|
606
|
+
TNever(schema) ||
|
|
607
|
+
TNot(schema) ||
|
|
608
|
+
TNull(schema) ||
|
|
609
|
+
TNumber(schema) ||
|
|
610
|
+
TObject(schema) ||
|
|
611
|
+
TPromise(schema) ||
|
|
612
|
+
TRecord(schema) ||
|
|
613
|
+
TRef(schema) ||
|
|
614
|
+
TString(schema) ||
|
|
615
|
+
TSymbol(schema) ||
|
|
616
|
+
TTemplateLiteral(schema) ||
|
|
617
|
+
TThis(schema) ||
|
|
618
|
+
TTuple(schema) ||
|
|
619
|
+
TUndefined(schema) ||
|
|
620
|
+
TUnion(schema) ||
|
|
621
|
+
TUint8Array(schema) ||
|
|
622
|
+
TUnknown(schema) ||
|
|
623
|
+
TUnsafe(schema) ||
|
|
624
|
+
TVoid(schema) ||
|
|
625
|
+
(TKind(schema) && TypeRegistry.Has(schema[exports.Kind])));
|
|
623
626
|
}
|
|
624
627
|
TypeGuard.TSchema = TSchema;
|
|
625
628
|
})(TypeGuard || (exports.TypeGuard = TypeGuard = {}));
|
|
@@ -995,8 +998,12 @@ var TypeExtends;
|
|
|
995
998
|
!TypeGuard.TObject(right) ? TypeExtendsResult.False :
|
|
996
999
|
(() => {
|
|
997
1000
|
for (const key of Object.getOwnPropertyNames(right.properties)) {
|
|
998
|
-
if (!(key in left.properties))
|
|
1001
|
+
if (!(key in left.properties) && !TypeGuard.TOptional(right.properties[key])) {
|
|
999
1002
|
return TypeExtendsResult.False;
|
|
1003
|
+
}
|
|
1004
|
+
if (TypeGuard.TOptional(right.properties[key])) {
|
|
1005
|
+
return TypeExtendsResult.True;
|
|
1006
|
+
}
|
|
1000
1007
|
if (Property(left.properties[key], right.properties[key]) === TypeExtendsResult.False) {
|
|
1001
1008
|
return TypeExtendsResult.False;
|
|
1002
1009
|
}
|