Never miss a switch case with TypeScript

Sébastien Dubois
4 min readMay 29, 2020

Switch statements are sometimes considered a code smell, but when they do make sense to use, you’d better make sure you don’t forget a single case. Luckily, TypeScript can help.

Image courtesy of Kelly Sikkema

In this article, I won’t discuss the reasons why you should avoid switch statements in your applications (e.g., they may easily violate the DRY and Open/Closed principles, may introduce subtle bugs if you forget a…

--

--