Used for exhaustive if/switch statements Example:
enum Fruit { orange = "orange", apple = "apple",}const getFruitName = (fruit: Fruit): string => { if (fruit === Fruit.orange) { return "Orange"; } // Should fail TS compilation as Fruit.apple is not being handled in the code above return assertUnreachable(fruit);} Copy
enum Fruit { orange = "orange", apple = "apple",}const getFruitName = (fruit: Fruit): string => { if (fruit === Fruit.orange) { return "Orange"; } // Should fail TS compilation as Fruit.apple is not being handled in the code above return assertUnreachable(fruit);}
Generated using TypeDoc
Used for exhaustive if/switch statements Example: