==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts (99 errors) ==== // checking whether other types are subtypes of type parameters with constraints class Foo { foo: T; } function f, U extends Foo, V extends Foo>(t: T, u: U, v: 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. ~~~~~~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. // error var r1 = true ? t : u; ~~~~~~~~~~~~ !!! No best common type exists between 'T' and 'U'. var r1 = 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(); ~~~~~~~~~~~~~~~~~~~~~~~ !!! No best common type exists between 'T' and 'Foo'. var r4 = true ? new Foo() : t; ~~~~~~~~~~~~~~~~~~~~~~~ !!! No best common type exists between 'Foo' and 'T'. // ok? var r5 = true ? u : new Foo(); ~~~~~~~~~~~~~~~~~~~~~~~ !!! No best common type exists between 'U' and 'Foo'. var r5 = true ? new Foo() : u; ~~~~~~~~~~~~~~~~~~~~~~~ !!! No best common type exists between 'Foo' and 'U'. // ok? 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'. // ok? var r7 = true ? t : new Foo(); ~~~~~~~~~~~~~~~~~~~~~~~ !!! No best common type exists between 'T' and 'Foo'. var r7 = true ? new Foo() : t; ~~~~~~~~~~~~~~~~~~~~~~~ !!! No best common type exists between 'Foo' and 'T'. // ok? var r8 = true ? u : new Foo(); ~~~~~~~~~~~~~~~~~~~~~~~ !!! No best common type exists between 'U' and 'Foo'. var r8 = true ? new Foo() : u; ~~~~~~~~~~~~~~~~~~~~~~~ !!! No best common type exists between 'Foo' and 'U'. // ok? var r9 = true ? v : new Foo(); ~~~~~~~~~~~~~~~~~~~~~~~ !!! No best common type exists between 'V' and 'Foo'. var r9 = true ? new Foo() : v; ~~~~~~~~~~~~~~~~~~~~~~~ !!! No best common type exists between 'Foo' and 'V'. // ok? var r10 = true ? t : new Foo(); ~~~~~~~~~~~~~~~~~~~~~~~ !!! No best common type exists between 'T' and 'Foo'. var r10 = true ? new Foo() : t; ~~~~~~~~~~~~~~~~~~~~~~~ !!! No best common type exists between 'Foo' and 'T'. // ok? var r11 = true ? u : new Foo(); ~~~~~~~~~~~~~~~~~~~~~~~ !!! No best common type exists between 'U' and 'Foo'. var r11 = true ? new Foo() : u; ~~~~~~~~~~~~~~~~~~~~~~~ !!! No best common type exists between 'Foo' and 'U'. // ok? var r12 = true ? v : new Foo(); ~~~~~~~~~~~~~~~~~~~~~~~ !!! No best common type exists between 'V' and 'Foo'. var r12 = true ? new Foo() : v; ~~~~~~~~~~~~~~~~~~~~~~~ !!! No best common type exists between 'Foo' and 'V'. } module M1 { class Base { foo: T; } class D1, U extends Foo, V extends Foo> extends Base { ~~~~~~~~~~~~~~~~ !!! 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. ~~~~~~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: T; foo: T } class D2, U extends Foo, V extends Foo> extends Base { ~~ !!! Class 'D2' incorrectly extends base class 'Base': !!! 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. ~~~~~~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: T; foo: U ~~~~~~ !!! Property 'foo' of type 'U' is not assignable to string index type 'T'. } class D3, U extends Foo, V extends Foo> extends Base { ~~ !!! Class 'D3' incorrectly extends base class 'Base': !!! 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. ~~~~~~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: T; foo: V ~~~~~~ !!! Property 'foo' of type 'V' is not assignable to string index type 'T'. } class D4, U extends Foo, V extends Foo> extends Base { ~~ !!! Class 'D4' incorrectly extends base class 'Base': !!! 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. ~~~~~~~~~~~~~~~~ !!! 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 D5, U extends Foo, V extends Foo> extends Base { ~~~~~~~~~~~~~~~~ !!! 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. ~~~~~~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: U; foo: U } class D6, U extends Foo, V extends Foo> extends Base { ~~ !!! Class 'D6' incorrectly extends base class 'Base': !!! 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. ~~~~~~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: U; foo: V ~~~~~~ !!! Property 'foo' of type 'V' is not assignable to string index type 'U'. } class D7, U extends Foo, V extends Foo> extends Base { ~~ !!! Class 'D7' incorrectly extends base class 'Base': !!! 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. ~~~~~~~~~~~~~~~~ !!! 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'. } class D8, U extends Foo, V extends Foo> extends Base { ~~ !!! Class 'D8' incorrectly extends base class 'Base': !!! 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. ~~~~~~~~~~~~~~~~ !!! 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'. } class D9, U extends Foo, V extends Foo> extends Base { ~~~~~~~~~~~~~~~~ !!! 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. ~~~~~~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: V; foo: V } } module M2 { class Base2 { foo: Foo; } class D1, U extends Foo, V extends Foo> extends Base2 { ~~~~~~~~~~~~~~~~ !!! 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. ~~~~~~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: T; foo: T } class D2, U extends Foo, V extends Foo> extends Base2 { ~~~~~~~~~~~~~~~~ !!! 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. ~~~~~~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: T; foo: U ~~~~~~ !!! Property 'foo' of type 'U' is not assignable to string index type 'T'. } class D3, U extends Foo, V extends Foo> extends Base2 { ~~~~~~~~~~~~~~~~ !!! 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. ~~~~~~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: T; foo: V ~~~~~~ !!! Property 'foo' of type 'V' is not assignable to string index type 'T'. } class D4, U extends Foo, V extends Foo> extends Base2 { ~~~~~~~~~~~~~~~~ !!! 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. ~~~~~~~~~~~~~~~~ !!! 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 D5, U extends Foo, V extends Foo> extends Base2 { ~~~~~~~~~~~~~~~~ !!! 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. ~~~~~~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: U; foo: U } class D6, U extends Foo, V extends Foo> extends Base2 { ~~~~~~~~~~~~~~~~ !!! 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. ~~~~~~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: U; foo: V ~~~~~~ !!! Property 'foo' of type 'V' is not assignable to string index type 'U'. } class D7, U extends Foo, V extends Foo> extends Base2 { ~~~~~~~~~~~~~~~~ !!! 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. ~~~~~~~~~~~~~~~~ !!! 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'. } class D8, U extends Foo, V extends Foo> extends Base2 { ~~~~~~~~~~~~~~~~ !!! 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. ~~~~~~~~~~~~~~~~ !!! 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'. } class D9, U extends Foo, V extends Foo> extends Base2 { ~~~~~~~~~~~~~~~~ !!! 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. ~~~~~~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. [x: string]: V; foo: V } }