Assert that this line is unreachable, useful for exhaustive checks such as a switch covering every case of a union.
switch
type Direction = 'up' | 'down';function describe(direction: Direction): string { switch (direction) { case 'up': return 'Going up'; case 'down': return 'Going down'; default: assertExhaustive(direction); // throws if a new Direction case isn't handled above }} Copy
type Direction = 'up' | 'down';function describe(direction: Direction): string { switch (direction) { case 'up': return 'Going up'; case 'down': return 'Going down'; default: assertExhaustive(direction); // throws if a new Direction case isn't handled above }}
Assert that this line is unreachable, useful for exhaustive checks such as a
switchcovering every case of a union.