I was anticipating the code to undergo type checking within Flow just like it does within TypeScript:
var onClick : (() => void) | (() => boolean);
onClick = () => { return true; }
However, I encountered this error instead:
4: onClick = () => { return true; }
^ function. Could not decide which case to select
3: var onClick : (() => void) | (() => boolean);
^ union type
Does this design decision have a specific name, and what is the rationale behind it?
Can we prompt the Flow checker to deduce the return type of a function from its return statements?