-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
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'.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue