3 ms·
If the Flow type checker ensures exhaustiveness, why does the switch statement require a default case and an `impossible` function?
by lnrdgmz 8y ago
If the Flow type checker ensures exhaustiveness, why does the switch statement require a default case and an `impossible` function?
- icebraining 8y agoRead the linked previous post[1]. Flow doesn't ensure exhaustiveness unless you ask it to, by telling it that any case that goes to "default" is invalid (impossible). [1] https://blog.jez.io/flow-exhaustiveness/ https://blog.jez.io/flow-exhaustiveness/
- frou_dh 8y agoMiserable hack.
- bgergen 8y agoYou can also just cast screen to empty in the default case by adding a line that says (screen: empty). This is how the flow docs recommend doing it in Redux reducers.