Hacker News new | ask | show | jobs
by lnrdgmz 2984 days ago
If the Flow type checker ensures exhaustiveness, why does the switch statement require a default case and an `impossible` function?
2 comments

Read 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/

Miserable hack.
You 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.