A type check function to ensure that a switch or set of conditionals is exhaustive. Typescript will throw an error if the switch or conditionals are not exhaustive.
type MyType = "a" | "b";function myFunction(value: MyType) { switch (value) { case "a": return "A"; case "b": return "B"; default: assertUnreachable(value); }} Copy
type MyType = "a" | "b";function myFunction(value: MyType) { switch (value) { case "a": return "A"; case "b": return "B"; default: assertUnreachable(value); }}
A type check function to ensure that a switch or set of conditionals is exhaustive. Typescript will throw an error if the switch or conditionals are not exhaustive.