How to ensure optimal discrimination of union types?
I have a union of types, each of which has an attribute with literal values that can in theory be used to quickly identify an appropriate top-level type. They all look like this:
Is there some way I can setup my types or configure arktype such that it does a breadth-first discrimination of types within a union? does it store the result of the matching type somewhere? and finally - I'd like to understand this logic a bit more, but I am completely unfamiliar with the code base, if someone could point me at the code for resolving type unions that would be very useful. Thanks!
1 Reply
Yes ArkType will do this by default. If you want to see what the structure of the discriminated union looks like, you could try something like
myModel.internal.assertHasKind("union").discriminantJson