Comparing version 1.0.25-alpha to 1.0.26-alpha
@@ -102,3 +102,5 @@ "use strict"; | ||
l, | ||
r | ||
r, | ||
lOptional: this.lOptional, | ||
rOptional: this.rOptional | ||
}; | ||
@@ -111,2 +113,4 @@ return empty; | ||
_defineProperty(this, "path", void 0); | ||
_defineProperty(this, "lOptional", void 0); | ||
_defineProperty(this, "rOptional", void 0); | ||
_defineProperty(this, "domain", void 0); | ||
@@ -120,2 +124,4 @@ _classPrivateFieldInit(this, _disjoints, { | ||
this.path = new _pathsJs.Path(); | ||
this.lOptional = false; | ||
this.rOptional = false; | ||
_classPrivateFieldSet(this, _disjoints, {}); | ||
@@ -122,0 +128,0 @@ } |
@@ -138,6 +138,9 @@ "use strict"; | ||
} | ||
const { l , r , kind } = intersectionState.disjoints[path]; | ||
const { l , r , kind , lOptional , rOptional } = intersectionState.disjoints[path]; | ||
if (!(0, _genericsJs.isKeyOf)(kind, discriminantKinds)) { | ||
continue; | ||
} | ||
if (lOptional || rOptional) { | ||
continue; | ||
} | ||
const lSerialized = serializeDefinitionIfAllowed(kind, l); | ||
@@ -144,0 +147,0 @@ const rSerialized = serializeDefinitionIfAllowed(kind, r); |
@@ -72,6 +72,13 @@ "use strict"; | ||
context.path.push(propKey); | ||
const previousLOptional = context.lOptional; | ||
const previousROptional = context.rOptional; | ||
(_context = context).lOptional || (_context.lOptional = isOptional(l)); | ||
(_context1 = context).rOptional || (_context1.rOptional = isOptional(r)); | ||
const result = (0, _nodeJs.nodeIntersection)(propToNode(l), propToNode(r), context); | ||
const resultIsOptional = context.lOptional && context.rOptional; | ||
context.rOptional = previousROptional; | ||
context.lOptional = previousLOptional; | ||
context.path.pop(); | ||
const resultIsOptional = isOptional(l) && isOptional(r); | ||
if ((0, _composeJs.isDisjoint)(result) && resultIsOptional) { | ||
var _context, _context1; | ||
// If an optional key has an empty intersection, the type can | ||
@@ -78,0 +85,0 @@ // still be satisfied as long as the key is not included. Set |
@@ -80,3 +80,5 @@ function _checkPrivateRedeclaration(obj, privateCollection) { | ||
l, | ||
r | ||
r, | ||
lOptional: this.lOptional, | ||
rOptional: this.rOptional | ||
}; | ||
@@ -89,2 +91,4 @@ return empty; | ||
_defineProperty(this, "path", void 0); | ||
_defineProperty(this, "lOptional", void 0); | ||
_defineProperty(this, "rOptional", void 0); | ||
_defineProperty(this, "domain", void 0); | ||
@@ -98,2 +102,4 @@ _classPrivateFieldInit(this, _disjoints, { | ||
this.path = new Path(); | ||
this.lOptional = false; | ||
this.rOptional = false; | ||
_classPrivateFieldSet(this, _disjoints, {}); | ||
@@ -100,0 +106,0 @@ } |
@@ -123,6 +123,9 @@ import { writeUndiscriminatableMorphUnionMessage } from "../parse/ast/union.js"; | ||
} | ||
const { l , r , kind } = intersectionState.disjoints[path]; | ||
const { l , r , kind , lOptional , rOptional } = intersectionState.disjoints[path]; | ||
if (!isKeyOf(kind, discriminantKinds)) { | ||
continue; | ||
} | ||
if (lOptional || rOptional) { | ||
continue; | ||
} | ||
const lSerialized = serializeDefinitionIfAllowed(kind, l); | ||
@@ -129,0 +132,0 @@ const rSerialized = serializeDefinitionIfAllowed(kind, r); |
@@ -54,6 +54,13 @@ import { composeIntersection, composeKeyedIntersection, equality, isDisjoint, isEquality } from "../compose.js"; | ||
context.path.push(propKey); | ||
const previousLOptional = context.lOptional; | ||
const previousROptional = context.rOptional; | ||
(_context = context).lOptional || (_context.lOptional = isOptional(l)); | ||
(_context1 = context).rOptional || (_context1.rOptional = isOptional(r)); | ||
const result = nodeIntersection(propToNode(l), propToNode(r), context); | ||
const resultIsOptional = context.lOptional && context.rOptional; | ||
context.rOptional = previousROptional; | ||
context.lOptional = previousLOptional; | ||
context.path.pop(); | ||
const resultIsOptional = isOptional(l) && isOptional(r); | ||
if (isDisjoint(result) && resultIsOptional) { | ||
var _context, _context1; | ||
// If an optional key has an empty intersection, the type can | ||
@@ -60,0 +67,0 @@ // still be satisfied as long as the key is not included. Set |
@@ -68,2 +68,4 @@ import type { Type } from "../scopes/type.js"; | ||
path: Path; | ||
lOptional: boolean; | ||
rOptional: boolean; | ||
domain: Domain | undefined; | ||
@@ -77,2 +79,4 @@ constructor(type: Type, lastOperator: "|" | "&"); | ||
kind: kind; | ||
lOptional: boolean; | ||
rOptional: boolean; | ||
} & DisjointKinds[kind]; | ||
@@ -79,0 +83,0 @@ declare const empty: unique symbol; |
{ | ||
"name": "arktype", | ||
"description": "TypeScript's 1:1 validator, optimized from editor to runtime", | ||
"version": "1.0.25-alpha", | ||
"version": "1.0.26-alpha", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "author": { |
Sorry, the diff of this file is not supported yet
499363
10789