Sometimes my function will throw. I want to add this to the return type. In TypeScript we set the return type to never. Is there an equivalent strategy in Flow?
Flow have empty type. Take a look at example of Typing Redux reducers, also can work as returned type for function.
/* @flow */
function foo():empty {
throw new Error();
}
function baz():empty {
return 42;
}
return 42;
^ Cannot return `42` because number [1] is incompatible with empty [2].
References:
8: return 42;
^ [1]
7: function baz():empty {
^ [2]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With