@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/typebox.js +9 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.27.7",
3
+ "version": "0.27.8",
4
4
  "description": "JSONSchema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",
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
- if (TypeGuard.TIntersect(schema))
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 (TypeGuard.TUnion(schema))
1414
+ if (schema[exports.Kind] === 'Union')
1409
1415
  return Union(schema, callback);
1410
- if (TypeGuard.TObject(schema))
1416
+ if (schema[exports.Kind] === 'Object')
1411
1417
  return Object(schema, callback);
1412
1418
  return schema;
1413
1419
  }