5 ms·
I love this, but I feel TypeScript would be very unhappy with such a thing.
by dickeytk 8y ago
I love this, but I feel TypeScript would be very unhappy with such a thing.
- y2bd 8y agoType it as `Record<string, R>` where `R` is your return type and you’d be fine in most cases. You could even make `R` a union type if necessary.
- alwaysdoit 8y agoBetween TSLint's no-switch-case-fall-through and an exhaustiveness check[1] I don't think any of these things are really problems with switch statements in TypeScript [1] Putting a function like this in a default case will enforce that all cases are declared at compile time: function exhaustive(exp: never): void {}