Closed
Description
Try pasting the following code into https://flow.org/try/
interface Foo {
kids: any[];
}
interface Bar {
category: "bar";
children: any[];
}
interface Baz {
category: "baz";
minions: any[];
}
for (let item of ([] : Array<Foo | Bar | Baz>)) {
if ("category" in item) {
// expecting item to be Bar | Baz here, or at least something with the property "category"
item.category
}
}
This code example works as expected in the TypeScript playground (provided you change the casting of the array literal using :
to as
, as TS uses different syntax for casting)