Open Gozala opened 7 years ago
It works if you rewrite your if statement like this:
if (result.isOk === true) {
It only works with ===
, not ==
. I am guessing this has to do with flow not wanting to pick a branch unless you make an exact match. In this case, I think Flow could allow matching loosely without losing soundness.
Here is an example of failure that I'd expect to work:
It fails to refine Result to
Ok
andError
byisOk
sentinel field as following erros seem to indicate:What's interesting that if I change classes to type definitions everything works as expected, but same error is present if interfaces are used
For whatever reason type refinements via switch instead of
if
seems to work in all cases: