==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts (94 errors) ==== // checking whether other types are subtypes of type parameters with constraints class C3 { foo: T; } class D1 extends C3 { ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: T; foo: T; // ok } class D2 extends C3 { ~~ !!! Class 'D2' incorrectly extends base class 'C3': !!! Types of property 'foo' are incompatible: !!! Type 'T' is not assignable to type 'U'. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: U; foo: T; // ok ~~~~~~~ !!! Property 'foo' of type 'T' is not assignable to string index type 'U'. } class D3 extends C3 { ~~ !!! Class 'D3' incorrectly extends base class 'C3': !!! Types of property 'foo' are incompatible: !!! Type 'U' is not assignable to type 'T'. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: T; foo: U; // error ~~~~~~~ !!! Property 'foo' of type 'U' is not assignable to string index type 'T'. } class D4 extends C3 { ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: U; foo: U; // ok } // V > U > T // test if T is subtype of T, U, V // should all work class D5 extends C3 { ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: T; foo: T; // ok } class D6 extends C3 { ~~ !!! Class 'D6' incorrectly extends base class 'C3': !!! Types of property 'foo' are incompatible: !!! Type 'T' is not assignable to type 'U'. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: U; foo: T; ~~~~~~~ !!! Property 'foo' of type 'T' is not assignable to string index type 'U'. } class D7 extends C3 { ~~ !!! Class 'D7' incorrectly extends base class 'C3': !!! Types of property 'foo' are incompatible: !!! Type 'T' is not assignable to type 'V'. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: V; foo: T; // ok ~~~~~~~ !!! Property 'foo' of type 'T' is not assignable to string index type 'V'. } // test if U is a subtype of T, U, V // only a subtype of V and itself class D8 extends C3 { ~~ !!! Class 'D8' incorrectly extends base class 'C3': !!! Types of property 'foo' are incompatible: !!! Type 'U' is not assignable to type 'T'. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: T; foo: U; // error ~~~~~~~ !!! Property 'foo' of type 'U' is not assignable to string index type 'T'. } class D9 extends C3 { ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: U; foo: U; // ok } class D10 extends C3 { ~~~ !!! Class 'D10' incorrectly extends base class 'C3': !!! Types of property 'foo' are incompatible: !!! Type 'U' is not assignable to type 'V'. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: V; foo: U; // ok ~~~~~~~ !!! Property 'foo' of type 'U' is not assignable to string index type 'V'. } // test if V is a subtype of T, U, V // only a subtype of itself class D11 extends C3 { ~~~ !!! Class 'D11' incorrectly extends base class 'C3': !!! Types of property 'foo' are incompatible: !!! Type 'V' is not assignable to type 'T'. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: T; foo: V; // error ~~~~~~~ !!! Property 'foo' of type 'V' is not assignable to string index type 'T'. } class D12 extends C3 { ~~~ !!! Class 'D12' incorrectly extends base class 'C3': !!! Types of property 'foo' are incompatible: !!! Type 'V' is not assignable to type 'U'. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: U; foo: V; // error ~~~~~~~ !!! Property 'foo' of type 'V' is not assignable to string index type 'U'. } class D13 extends C3 { ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: V; foo: V; // ok } // Date > V > U > T // test if T is subtype of T, U, V, Date // should all work class D14 extends C3 { ~~~ !!! Class 'D14' incorrectly extends base class 'C3': !!! Types of property 'foo' are incompatible: !!! Type 'T' is not assignable to type 'Date'. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: Date; foo: T; // ok ~~~~~~~ !!! Property 'foo' of type 'T' is not assignable to string index type 'Date'. } class D15 extends C3 { ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: T; foo: T; // ok } class D16 extends C3 { ~~~ !!! Class 'D16' incorrectly extends base class 'C3': !!! Types of property 'foo' are incompatible: !!! Type 'T' is not assignable to type 'U'. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: U; foo: T; ~~~~~~~ !!! Property 'foo' of type 'T' is not assignable to string index type 'U'. } class D17 extends C3 { ~~~ !!! Class 'D17' incorrectly extends base class 'C3': !!! Types of property 'foo' are incompatible: !!! Type 'T' is not assignable to type 'V'. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: V; foo: T; ~~~~~~~ !!! Property 'foo' of type 'T' is not assignable to string index type 'V'. } // test if U is a subtype of T, U, V, Date // only a subtype of V, Date and itself class D18 extends C3 { ~~~ !!! Class 'D18' incorrectly extends base class 'C3': !!! Types of property 'foo' are incompatible: !!! Type 'T' is not assignable to type 'Date'. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: Date; foo: T; // ok ~~~~~~~ !!! Property 'foo' of type 'T' is not assignable to string index type 'Date'. } class D19 extends C3 { ~~~ !!! Class 'D19' incorrectly extends base class 'C3': !!! Types of property 'foo' are incompatible: !!! Type 'U' is not assignable to type 'T'. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: T; foo: U; // error ~~~~~~~ !!! Property 'foo' of type 'U' is not assignable to string index type 'T'. } class D20 extends C3 { ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: U; foo: U; // ok } class D21 extends C3 { ~~~ !!! Class 'D21' incorrectly extends base class 'C3': !!! Types of property 'foo' are incompatible: !!! Type 'U' is not assignable to type 'V'. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: V; foo: U; ~~~~~~~ !!! Property 'foo' of type 'U' is not assignable to string index type 'V'. } // test if V is a subtype of T, U, V, Date // only a subtype of itself and Date class D22 extends C3 { ~~~ !!! Class 'D22' incorrectly extends base class 'C3': !!! Types of property 'foo' are incompatible: !!! Type 'T' is not assignable to type 'Date'. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: Date; foo: T; // ok ~~~~~~~ !!! Property 'foo' of type 'T' is not assignable to string index type 'Date'. } class D23 extends C3 { ~~~ !!! Class 'D23' incorrectly extends base class 'C3': !!! Types of property 'foo' are incompatible: !!! Type 'V' is not assignable to type 'T'. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: T; foo: V; // error ~~~~~~~ !!! Property 'foo' of type 'V' is not assignable to string index type 'T'. } class D24 extends C3 { ~~~ !!! Class 'D24' incorrectly extends base class 'C3': !!! Types of property 'foo' are incompatible: !!! Type 'V' is not assignable to type 'U'. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: U; foo: V; // error ~~~~~~~ !!! Property 'foo' of type 'V' is not assignable to string index type 'U'. } class D25 extends C3 { ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: V; foo: V; // ok } // test if Date is a subtype of T, U, V, Date // only a subtype of itself class D26 extends C3 { ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: Date; foo: Date; // ok } class D27 extends C3 { ~~~ !!! Class 'D27' incorrectly extends base class 'C3': !!! Types of property 'foo' are incompatible: !!! Type 'Date' is not assignable to type 'T'. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: T; foo: Date; // error ~~~~~~~~~~ !!! Property 'foo' of type 'Date' is not assignable to string index type 'T'. } class D28 extends C3 { ~~~ !!! Class 'D28' incorrectly extends base class 'C3': !!! Types of property 'foo' are incompatible: !!! Type 'Date' is not assignable to type 'U'. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: U; foo: Date; // error ~~~~~~~~~~ !!! Property 'foo' of type 'Date' is not assignable to string index type 'U'. } class D29 extends C3 { ~~~ !!! Class 'D29' incorrectly extends base class 'C3': !!! Types of property 'foo' are incompatible: !!! Type 'Date' is not assignable to type 'V'. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: V; foo: Date; // error ~~~~~~~~~~ !!! Property 'foo' of type 'Date' is not assignable to string index type 'V'. }