4 ms·
Typescript supports exhaustive switches which are pretty powerful, especially when working with proper union types and the like.
by myvoiceismypass 4y ago
Typescript supports exhaustive switches which are pretty powerful, especially when working with proper union types and the like.
- adam_arthur 4y agoI find using objects mapped as switchKeyToFunction to be more idiomatic and readable. e.g. shapeToDrawFn[shape] But to each their own
- phs2501 4y agoWill the compiler check that you have an exhaustive set of keys in your definition of `shapeToDrawFn`? (Not a rhetorical question, I don't know.)