I seriously cannot think of a more basic use case of Union types than this:
test.js
// @flow
type Foo = {
a: string,
b: number
}
function func(o: Foo | string) {
if (o instanceof Foo) { // <<<<< ERROR
console.log(o.a);
} else {
console.log(o);
}
}
Flow gives me an error on the line:
o instanceof Foo
with this:
Cannot reference type Foo [1] from a value position.
What am I doing wrong and how do I make this logic work?