Starting with v0.32.0, Flow does not complain about unreachable code, unless something like
However, consider the following code
There will be no errors in this code at this time. The thread actually notes that x === 123 will never be true. Inside the if block, the thread will refine the type x to an empty type, since it does not believe that this code will ever be reached. This is why it does not complain about the return x .
One member of the Flow team is almost complete with the addition of availability analysis for the flow. As soon as this improvement lands (I assume v0.34.0?), Flow will complain when it sees a condition that, in its opinion, will always fail. This will help you in your example, since the cases of switch statements are basically strict equality checks.
source share