TypeScript's 1:1 validator, optimized from editor to runtime
Improve static parse error contextual summaries
Thanks @Hsiwe! https://github.com/arktypeio/arktype/pull/873
Previously, a scoped type like this failed to infer correctly. Thanks to @Vanilagy for the repro!
scope({
a: {
name: '"a"'
},
b: {
name: '"b"',
children: "(a|b)[]"
}
})
unknown
Unfortunately, some cross-scope operations will still result in an error at runtime. You will know at build time if this occurs by a message in an intersection like "Unable to resolve alias 'myExternalAlias'". The workaround is to use the in-scope type parser as follows until next release for these scenarios:
Unions:
const $ = scope({
a: "'abc'",
b: { "c?": "a" }
})
const types = $.compile()
// This fails if you don't use scoped type for now, fixing in next release
const t = $.type([types.b, "|", { extraProp: "string" }])
Intersections:
const $ = scope({
a: "'abc'",
b: { "c?": "a" }
})
const types = $.compile()
// This fails if you don't use scoped type for now, fixing in next release
const t = $.type([types.b, "&", { extraProp: "string" }])