// @flow
type A = {
tag: 'a',
};
type B = {
tag: 'b',
};
type Foo = A | B;
const bar = (x: Foo, y: Foo) => {
if (x.tag === 'a') {
return 'x is a';
} else if (y.tag === 'a') {
return 'y ix a';
} else if (x.tag === 'b' && y.tag === 'b') {
return 'both are b';
} else {
(x: empty);
(y: empty);
}
}
All cases are covered by the first three branches in the if/else, so the empty assertions in the last branch should be correct. As an example, Flow correctly identifies this when we assert that x and y are both B (Flow try link).
Hello Flow team!
[Flow try link]
All cases are covered by the first three branches in the if/else, so the
empty
assertions in the last branch should be correct. As an example, Flow correctly identifies this when we assert thatx
andy
are bothB
(Flow try link).