Files
CHOMPStation2/tgui/packages/common/exhaustive.ts
Heroman3003 7144410a11 TGUI Update
2023-06-01 00:31:00 +00:00

20 lines
506 B
TypeScript

/**
* Throws an error such that a non-exhaustive check will error at compile time
* when using TypeScript, rather than at runtime.
*
* For example:
* enum Color { Red, Green, Blue }
* switch (color) {
* case Color.Red:
* return "red";
* case Color.Green:
* return "green";
* default:
* // This will error at compile time that we forgot blue.
* exhaustiveCheck(color);
* }
*/
export const exhaustiveCheck = (input: never) => {
throw new Error(`Unhandled case: ${input}`);
};