==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts (47 errors) ==== // type parameters are not assignable to one another unless directly or indirectly constrained to one another function foo(t: T, u: U) { ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. t = u; // error ~ !!! Type 'U' is not assignable to type 'T'. u = t; // ok ~ !!! Type 'T' is not assignable to type 'U'. } function foo2(t: T, u: U) { ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. t = u; // error ~ !!! Type 'U' is not assignable to type 'T'. u = t; // ok ~ !!! Type 'T' is not assignable to type 'U'. } function foo3(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. t = u; // error ~ !!! Type 'U' is not assignable to type 'T'. u = t; ~ !!! Type 'T' is not assignable to type 'U'. t = v; // error ~ !!! Type 'V' is not assignable to type 'T'. v = t; // ok ~ !!! Type 'T' is not assignable to type 'V'. u = v; // error ~ !!! Type 'V' is not assignable to type 'U'. v = u; // ok ~ !!! Type 'U' is not assignable to type 'V'. } function foo4(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. t = u; // error ~ !!! Type 'U' is not assignable to type 'T'. t = v; // error ~ !!! Type 'V' is not assignable to type 'T'. t = new Date(); // error ~ !!! Type 'Date' is not assignable to type 'T'. u = t; ~ !!! Type 'T' is not assignable to type 'U'. u = v; // error ~ !!! Type 'V' is not assignable to type 'U'. u = new Date(); // error ~ !!! Type 'Date' is not assignable to type 'U'. v = t; ~ !!! Type 'T' is not assignable to type 'V'. v = u; ~ !!! Type 'U' is not assignable to type 'V'. v = new Date(); // ok ~ !!! Type 'Date' is not assignable to type 'V'. var d: Date; d = t; // ok ~ !!! Type 'T' is not assignable to type 'Date'. d = u; // ok ~ !!! Type 'U' is not assignable to type 'Date'. d = v; // ok } // same as foo4 with different type parameter ordering function foo5(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. t = u; // error ~ !!! Type 'U' is not assignable to type 'T'. t = v; // error ~ !!! Type 'V' is not assignable to type 'T'. t = new Date(); // error ~ !!! Type 'Date' is not assignable to type 'T'. u = t; ~ !!! Type 'T' is not assignable to type 'U'. u = v; // error ~ !!! Type 'V' is not assignable to type 'U'. u = new Date(); // error ~ !!! Type 'Date' is not assignable to type 'U'. v = t; ~ !!! Type 'T' is not assignable to type 'V'. v = u; ~ !!! Type 'U' is not assignable to type 'V'. v = new Date(); // ok ~ !!! Type 'Date' is not assignable to type 'V'. var d: Date; d = t; // ok ~ !!! Type 'T' is not assignable to type 'Date'. d = u; // ok ~ !!! Type 'U' is not assignable to type 'Date'. d = v; // ok } function foo6(t: T, u: U, v: V) { ~~~~~~~~~~~ !!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list. t = u; // error ~ !!! Type 'U' is not assignable to type 'T'. t = v; // error ~ !!! Type 'V' is not assignable to type 'T'. u = t; // ok ~ !!! Type 'T' is not assignable to type 'U'. u = v; // error ~ !!! Type 'V' is not assignable to type 'U'. v = t; // error ~ !!! Type 'T' is not assignable to type 'V'. v = u; // error ~ !!! Type 'U' is not assignable to type 'V'. }