this post was submitted on 15 Mar 2024
13 points (93.3% liked)
TypeScript
820 readers
1 users here now
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Generally, I would recommend against throwing in the
default
case, since it will actually reduce your type safety (exceptions bypass all your other types). But I learned that with another clever trick this can be avoided, giving both runtime and compile time safety: https://exploringjs.com/tackling-ts/ch_enums.html#exhaustiveness-checks