Open aij opened 6 years ago
I believe this is a more concise example of the issue:
// @flow
type A = {| foo: number | string |};
type B = {| foo: number | string |};
type C = {| foo: number | string |};
const d: $Diff<A, B> = {...null};
const e: $Diff<A & B, B> = {...null};
const f: $Diff<A & B, A & B> = {...null};
const g: $Diff<A & B, A & C> = {...null}; // should not error.
I would expect type intersections to be associative, like set intersections, but sometimes they are not. This came up in real code, using type aliases rather than parentheses.
The gist of it is is that
typechecks, while
does not.
I was able to isolate the problematic code enough to reproduce in the sandbox, with v0.77.
I expect the example can be minimized a little further (particularly the part extracted from flow-typed), but I wanted to double check that this really is a bug before spending more time on it. Here is the same example from the sandbox for your convenience: