Assign never in the default branch to force compile errors when a union grows and you forget a case.
Compiler help
With noImplicitReturns and never assignments, adding a union member becomes a compile error until every switch handles it—cheap regression safety.
Self-check
- Add a
defaultbranch assigningthemetonever.
Exhaustiveness pairs well with discriminated unions when product teams add new enum-like states every sprint.
Practice: Apply exhaustiveness in the playground, then explain exhaustiveness in one sentence without looking at notes.