Open DanielHeath opened 7 years ago
I think I've experienced a similar issue trying to get certain mori types working in flow >= 0.23.
I have to reverse the order of the intersection there to get this line to type-check.
Hmm, this certainly isn't ideal, but I wonder what the right answer is. In this case, both Props
and Object
have (different) ways to look up .item
, one of which (string property lookup) returns any
and one of which returns a specific object type. I wonder how Flow should decide which one to use...
There are a few situations where (imo) the right thing to do is clear - I'm unsure whether it would be more or less confusing to have flow pick the right one sometimes but guess or fail other times.
For instance, Foo & any
is Foo
; same for Object if Foo
is a kind of object. Structural types are already doing the right thing IIRC.
Example:
https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVAXAngBwKZgCSGeAtmALxgDeAHgFxgD81AlgCaMDOGATqwDsA5gF8RmXAQAKvODi6UaYViVKNiZMCIDc6KAFcBAYwys4AsADE4cABQBKGqjAuwtnLPmMA8gCMAVngmYABkYDJyXI4UAHxgHpEAdCpkyey6OnqGJmYWAEIAhrwOTq5uCV7hngphfoEm0XEVXMmqaRm6QA
Expected: Intersecting two types would be commutative. Actual: Order matters.