DEV Community

Discussion on: Exhaustive Type Checking with TypeScript!

Collapse
 
vimkin profile image
Vadim Kalinin

I came up with the idea, that throwing an error inside the function solely created for this purpose (in your case exhaustiveCheck) feels somehow odd. Throwing the error directly (e.g. UnsupportedValueError(x)) or declaring the output type for the function explicitly feels more natural. For interested, both cases are described in detail here: 2ality.com/2020/02/typescript-exha....

imho using a helper library that replicates the switch for exhaustive checking which is already supported by the typescript feels unnecessary.