Flow - array of subtypes

Viewed 339

Having two objects, where B extends A, I can assign single instance of B to variable of type A. However, with arrays, that is not possible. Is there anything I can do to make this work? Thanks!

// @flow
type ObjectA = { foo: string };
type ObjectB = ObjectA & {bar: number };

let objectBArray: ObjectB[] = [{ foo: 'test', bar: 42 }];
let objectAArray: ObjectA[] = objectBArray; // Does not work!
1 Answers
Related