Flow: BUG: truthyness test of nullable arg doesn't carry over into closure

Created on 9 Dec 2016  路  3Comments  路  Source: facebook/flow

const fn = (Y: ?() => void) => Y && setTimeout(() => Y(), 10)
                                                     ^--

this code gives me an error saying Y might be null or undefined -- when in fact, there's no way it could be.

Another example of this bug:
```js
const x = (n: number) => 10
const fn2 = (Y: ?number) => Y && (() => x(Y))
````
It again things that Y might somehow be null/undefined inside the closure.

not a bug refinements

Most helpful comment

I get being cautious w/ object members, but in this case flow should be able to trivially determine that nothing can modify Y

All 3 comments

I get being cautious w/ object members, but in this case flow should be able to trivially determine that nothing can modify Y

Any update on this issue? Will it be fixed soon?

Was this page helpful?
0 / 5 - 0 ratings