A discriminated union is a union of objects that share a common literal property, the discriminant (often type or kind). Testing this property narrows the union to the right variant. With an exhaustive switch, the compiler flags any forgotten case.
Example
type Forme =
| { type: 'cercle'; rayon: number }
| { type: 'carre'; cote: number };