==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts (18 errors) ==== // checking whether other types are subtypes of type parameters with constraints class Foo { foo: number; } function f(t: T, u: U, v: V) { // error var r = true ? t : u; ~~~~~~~~~~~~ !!! No best common type exists between 'T' and 'U'. var r = true ? u : t; ~~~~~~~~~~~~ !!! No best common type exists between 'U' and 'T'. // error var r2 = true ? t : v; ~~~~~~~~~~~~ !!! No best common type exists between 'T' and 'V'. var r2 = true ? v : t; ~~~~~~~~~~~~ !!! No best common type exists between 'V' and 'T'. // error var r3 = true ? v : u; ~~~~~~~~~~~~ !!! No best common type exists between 'V' and 'U'. var r3 = true ? u : v; ~~~~~~~~~~~~ !!! No best common type exists between 'U' and 'V'. // ok var r4 = true ? t : new Foo(); var r4 = true ? new Foo() : t; // ok var r5 = true ? u : new Foo(); var r5 = true ? new Foo() : u; // BUG, should be error var r6 = true ? v : new Foo(); ~~~~~~~~~~~~~~~~~~~~ !!! No best common type exists between 'V' and 'Foo'. var r6 = true ? new Foo() : v; ~~~~~~~~~~~~~~~~~~~~ !!! No best common type exists between 'Foo' and 'V'. } class B1 { foo: T; } class D1 extends B1 { [x: string]: Foo; foo: T; // ok } class D2 extends B1 { [x: string]: Foo; foo: U; // ok } class D3 extends B1 { ~~ !!! Class 'D3' incorrectly extends base class 'B1': !!! Types of property 'foo' are incompatible: !!! Type 'V' is not assignable to type 'Foo': !!! Property 'foo' is missing in type '{}'. [x: string]: Foo; foo: V; // error ~~~~~~~ !!! Property 'foo' of type 'V' is not assignable to string index type 'Foo'. } class D4 extends B1 { [x: string]: T; foo: T; // ok } class D5 extends B1 { ~~ !!! Class 'D5' incorrectly extends base class 'B1': !!! Types of property 'foo' are incompatible: !!! Type 'U' is not assignable to type 'T'. [x: string]: T; foo: U; // error ~~~~~~~ !!! Property 'foo' of type 'U' is not assignable to string index type 'T'. } class D6 extends B1 { ~~ !!! Class 'D6' incorrectly extends base class 'B1': !!! Types of property 'foo' are incompatible: !!! Type 'V' is not assignable to type 'T'. [x: string]: T; foo: V; // error ~~~~~~~ !!! Property 'foo' of type 'V' is not assignable to string index type 'T'. } class D7 extends B1 { ~~ !!! Class 'D7' incorrectly extends base class 'B1': !!! Types of property 'foo' are incompatible: !!! Type 'T' is not assignable to type 'U'. [x: string]: U; foo: T; // error ~~~~~~~ !!! Property 'foo' of type 'T' is not assignable to string index type 'U'. } class D8 extends B1 { [x: string]: U; foo: U; // ok } class D9 extends B1 { ~~ !!! Class 'D9' incorrectly extends base class 'B1': !!! Types of property 'foo' are incompatible: !!! Type 'V' is not assignable to type 'U'. [x: string]: U; foo: V; // error ~~~~~~~ !!! Property 'foo' of type 'V' is not assignable to string index type 'U'. }