Ultimate

X_SCHEMA_DISCRIMINANT_INVALID

Means

a discriminated union member can never be dispatched to

Typical cause

a member of t.discriminatedUnion('<key>', […]) that declares no literal at the discriminant, or one whose tag an earlier member already claims. Thrown where the union is built, not where a value is parsed: a member no tag routes to is wrong for every input, so the first import of the authoring file is the earliest honest place to say so

Fix

give the member named in cause a literal discriminant — t.object({ <key>: t.literal('…'), … }) — its own value at that key, or merge the two members into one; t.union(...) if the members share no key

Listed under Schema and validation

This page as markdown