I keep running into more complex version of this example code fairly often:
/* @flow */
const exmpl = (input:number):number => {
while (true) {
switch (input) {
case 0:
return input
default:
return 0
}
}
}
Which flow fails to type check with a following error:
3: const exmpl = (input:number):number => {
^ number. This type is incompatible with an implicitly-returned undefined.
Most likely flow is failing to infer that while block will ever be executed. I am not sure how difficult would it be make flow type check this code, but either way it would really help if flow provided a hint on why it assumes implicitly returned undefined something, telling user that while block may never run would greatly improve usability.