#exhaustive Clear
Tags #php #kotlin #bash #go #sql #rust #typescript #html #java #python #files #utils #strings #http #concurrency #async #json #arrays #security #types #crypto #database #dates #format
Python Literal + match for Exhaustive Switching
`Literal` pins a value to specific strings/ints. Combine with the match statement (Python 3.10+) and a `_ : assert_never` clause for exhaustiveness — every variant must be handled or mypy yells at you.
TypeScript Exhaustive `assertNever`
Compile-time guarantee that every variant of a union is handled. When you add a new variant later, every switch missing that case becomes a type error. The runtime version is a safety net.
TypeScript Discriminated Unions with Exhaustive Switch
Discriminated (tagged) unions give you compiler-checked state machines. Pair with `assertNever` to force every new variant to be handled at every switch site — refactors stop being scary.
Kotlin Sealed Classes — Closed Type Hierarchies
`sealed` restricts subclassing to the same module. Combined with exhaustive `when`, the compiler enforces handling of every variant — refactor-friendly state machines.