Objects participating in === comparison fail to typecheck
Test case:
var obj;
if (obj.x == 1); // error: Property cannot be accessed on possibly undefined value
if (obj.x === 1); // no error ?!
(running Flow 0.14.0)
See #698 :)
I believe this is a different issue: the problem is not in accessing possibly non-existent property (x), but in accessing it on a possibly undefined object (obj). The code as written will cause a runtime error, Flow better warn me about this :)
Yes indeed, sorry, my comment was not very comprehensible but I wanted to say that this is (a bug ?) caused by the refinement recently introduiced.
This bug seems to be fixed in v0.21:
examples/01-variables/01-variables.js:31
31: if (obj.x == 1); // error: Property cannot be accessed on possibly undefined value
^^^^^ property `x`. Property not found in possibly undefined value
31: if (obj.x == 1); // error: Property cannot be accessed on possibly undefined value
^^^ uninitialized variable
examples/01-variables/01-variables.js:32
32: if (obj.x === 1); // no error ?!
^^^^^ property `x`. Property not found in possibly undefined value
32: if (obj.x === 1); // no error ?!
^^^ uninitialized variable
examples/01-variables/01-variables.js:32
32: if (obj.x === 1); // no error ?!
^ property `x`. Property not found in possibly undefined value
32: if (obj.x === 1); // no error ?!
^^^ uninitialized variable
@pasha-mf gonna close this based on @raquo's comment, but please let me know if it's not fixed