DEV Community

Discussion on: Exhaustive Type Checking with TypeScript!

Collapse
 
ionutgi profile image
IonutGI • Edited

Exhaustiveness checking seems like the 'default' behavior for the above switch statements.

Great article though.

Collapse
 
cubiclebuddha profile image
Cubicle Buddha

Yes, but it’s more explicit. Even in C# (which doesn’t have exhaustiveness checking like TypeScript), the best practice is to throw an error in the default case that says “unexpected case”. The benefit of TS is that it can catch those unexpected cases at compile time too! :)

Collapse
 
ionutgi profile image
IonutGI

Agreed. Thanks a lot.