Closed
Description
TypeScript Version: 2.0.0
Code
class A {
a: string;
}
class B extends A {
b: string;
}
function f(a: ReadonlyArray<A>): void { }
f([new A()]); // OK
f([new A(), new B()]); // OK
f([new B()]); // Error
Expected behavior:
To compile.
Actual behavior:
error TS2345: Argument of type 'B[]' is not assignable to parameter of type 'ReadonlyArray'.
Types of property 'concat' are incompatible.
Type '(...items: (B | B[])[]) => B[]' is not assignable to type '{ <U extends ReadonlyArray>(...items: U[]): A[]; (...items: A[]): A[]; }'.
Types of parameters 'items' and 'items' are incompatible.
Type 'A' is not assignable to type 'B | B[]'.
Type 'A' is not assignable to type 'B[]'.
Property 'length' is missing in type 'A'.