@sinclair/typebox 0.27.7 → 0.27.8
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 +9 -3
package/package.json
CHANGED
package/typebox.js
CHANGED
|
@@ -1394,20 +1394,26 @@ var TypeClone;
|
|
|
1394
1394
|
var ObjectMap;
|
|
1395
1395
|
(function (ObjectMap) {
|
|
1396
1396
|
function Intersect(schema, callback) {
|
|
1397
|
+
// prettier-ignore
|
|
1397
1398
|
return exports.Type.Intersect(schema.allOf.map((inner) => Visit(inner, callback)), { ...schema });
|
|
1398
1399
|
}
|
|
1399
1400
|
function Union(schema, callback) {
|
|
1401
|
+
// prettier-ignore
|
|
1400
1402
|
return exports.Type.Union(schema.anyOf.map((inner) => Visit(inner, callback)), { ...schema });
|
|
1401
1403
|
}
|
|
1402
1404
|
function Object(schema, callback) {
|
|
1403
1405
|
return callback(schema);
|
|
1404
1406
|
}
|
|
1405
1407
|
function Visit(schema, callback) {
|
|
1406
|
-
|
|
1408
|
+
// There are cases where users need to map objects with unregistered kinds. Using a TypeGuard here would
|
|
1409
|
+
// prevent sub schema mapping as unregistered kinds will not pass TSchema checks. This is notable in the
|
|
1410
|
+
// case of TObject where unregistered property kinds cause the TObject check to fail. As mapping is only
|
|
1411
|
+
// used for composition, we use explicit checks instead.
|
|
1412
|
+
if (schema[exports.Kind] === 'Intersect')
|
|
1407
1413
|
return Intersect(schema, callback);
|
|
1408
|
-
if (
|
|
1414
|
+
if (schema[exports.Kind] === 'Union')
|
|
1409
1415
|
return Union(schema, callback);
|
|
1410
|
-
if (
|
|
1416
|
+
if (schema[exports.Kind] === 'Object')
|
|
1411
1417
|
return Object(schema, callback);
|
|
1412
1418
|
return schema;
|
|
1413
1419
|
}
|