New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exact intersection type works. Should it? #5626

knyzorg opened this Issue Jan 8, 2018 · 0 comments


None yet
1 participant

knyzorg commented Jan 8, 2018

type A = {| foo: string |};
type B = { bar: number };
type AB = B & A;

declare var abc:AB;

// Doesn't work, obviously
abc.d = 3;

// Works... okay... = 'test'; = 123;

// Doesn't work??
const ab: AB = { foo: 'test', bar: 123 };

Online sample

Basically, what the AB type is suppose to mean a type which is EXACTLY like A but also intersects with B. The only possible intersection is where an object is exactly like A and B features all necessary properties.

It is late, I am tired and confused. Either this is a bug in Flow or this thread is misleading. If the latter is true, then the weirdness in my code sample above should be explained and documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment