3 ms·
The article mentions a non handled case in a switch is flagged in Reason but not TypeScript. That is technically true, but you can flag an unhandled case by add
by city41 7y ago
The article mentions a non handled case in a switch is flagged in Reason but not TypeScript. That is technically true, but you can flag an unhandled case by adding a default case which takes advantage of the never type
https://stackoverflow.com/questions/39419170/how-do-i-check-that-a-switch-block-is-exhaustive-in-typescript https://stackoverflow.com/questions/39419170/how-do-i-check-...
- loxs 7y agoThis isn't needed any more. Modern TS enforces switch exhaustiveness out-of-the box (if you provide the proper union type, of course).
- city41 7y agoOh awesome, I didn't know that. Thanks for the heads up.
- sikan 7y agoThis is not true: https://www.typescriptlang.org/docs/handbook/advanced-types.html#exhaustiveness-checking https://www.typescriptlang.org/docs/handbook/advanced-types....
- loxs 7y agoYeah, I always use strict and specify return type. IMO, still counts.