Ask questionsType refinement stopped working in 0.125
Flow version: 0.125
The type refinement works as expected (it did in 0.124). In the last version methods written like this produced the expected return type based on the type parameter that was passed. Now, these methods fail the type check.
You can see this even better here
If you change
foo.isB you get a type error. Which is correct because after
create('A') the result must be of type
A and can't be
Answer questions dsainati1
The fix for this is quite complex and might not be able to come out before the planned rework of utility types planned for this year. Is it possible to rewrite this code to avoid the use of
$ElementType? You might try overloading the definition of this function instead?
(Alternatively it would be totally reasonable to suppress this error)