Flow version: 0.94.0
Since flow won't know whether the closure is called or not, I would expect the type of a to be string | number
Type of a is string
function myFunc(): string {
let a = "a string";
[1].forEach(() => {
a = 2;
});
return a; // a is string
}
Yikes. This is pretty scary. Thanks for pointing this out. I think we have a fix in the works that should be out in one of the next versions.
Most helpful comment
Yikes. This is pretty scary. Thanks for pointing this out. I think we have a fix in the works that should be out in one of the next versions.