Unions with optional params?
Are unions with optional params supported in arktype?
Example:
https://stackblitz.com/edit/fhz11y?file=type.ts
Example:
https://stackblitz.com/edit/fhz11y?file=type.ts
import { type, union } from "arktype"
const a = type({
direction: "'forward' | 'backward'",
"operator?": "'by'"
})
const b = type({
duration: "'s' | 'min' | 'h'",
"operator?": "'to'"
})
const c = union(a, b)
type TypeC = typeof c.infer
const test: TypeC = {
direction: "forward"
}
console.log("a", a(test))
console.log("c", c(test))
c.assert(test) // operator must be 'by' or 'to' (was undefined)