You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have a union type where the first (by alphabetically) property of the first option has the same name as a property on a later option but with a different type, and then you have an object of the second type that has a value for that property which happens to also fit the type of the first option's first property, then Flow incorrectly gives a type error instead of realizing that the value belongs to the second option.
[chris /tmp/foo]$ flow version
Flow, a static type checker for JavaScript, version 0.21.0
[chris /tmp/foo]$ flow
bar.js:5
5: {b: true}
^^^^^^^^^ object literal. This type is incompatible with
3: var bar: Array<{b: ?boolean, c: number} | {b: boolean}> = [
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ union: object type(s)
Found 1 error
The following changes each cause Flow to correctly not give any errors:
I'm not familiar with Flow's own code, but I'd make a wild guess that Flow is incorrectly choosing not to backtrack after it sees a property in an object fit a property in an option and no further options have a property of the same exact type, even though further options might have a same-named property of a compatible type.
The text was updated successfully, but these errors were encountered:
If you have a union type where the first (by alphabetically) property of the first option has the same name as a property on a later option but with a different type, and then you have an object of the second type that has a value for that property which happens to also fit the type of the first option's first property, then Flow incorrectly gives a type error instead of realizing that the value belongs to the second option.
The following changes each cause Flow to correctly not give any errors:
b
property to match the type of theb
property on the second option.b
. ("c" -> "a" in the example.)I'm not familiar with Flow's own code, but I'd make a wild guess that Flow is incorrectly choosing not to backtrack after it sees a property in an object fit a property in an option and no further options have a property of the same exact type, even though further options might have a same-named property of a compatible type.
The text was updated successfully, but these errors were encountered: