Exhaustiveness checking seems like the 'default' behavior for the above switch statements.
Great article though.
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! :)
Agreed. Thanks a lot.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.