You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Incorrect return values from functions should throw.
The above is a contrived example, but I've had to set the return value to a value of the expected type explicitly to get the type checking. My specific use case is that I'm using Ramda and would really like runtime flow checks on it because static flow type checks are not really going to happen for it.
Which package versions are you using?
version 0.7.0
The text was updated successfully, but these errors were encountered:
This happens because we can only reliably/safely check functions with annotations, otherwise there would be so many failures as to make the library totally impractical. This is also how flow does it in scenarios where it can't infer return types - it accepts Any<Function>. To get around this, you'll need to add your annotation to the function directly:
typeStrFunType=()=>string;conststrFun: StrFunType=(): string=>'abc';// this is fineconstnumFun: StrFunType=(): number=>123;// should throw
This is a:
Which concerns:
What is the current behaviour?
strFun() should throw because it did not return a string. Instead, I have to do the following in order to get it to throw:
What is the expected behaviour?
Incorrect return values from functions should throw.
The above is a contrived example, but I've had to set the return value to a value of the expected type explicitly to get the type checking. My specific use case is that I'm using Ramda and would really like runtime flow checks on it because static flow type checks are not really going to happen for it.
Which package versions are you using?
version 0.7.0
The text was updated successfully, but these errors were encountered: