TypeScript/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference2.errors.txt
2014-07-24 19:39:50 -07:00

17 lines
763 B
Plaintext

==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithConstraintsTypeArgumentInference2.ts (2 errors) ====
// Generic call with parameters of T and U, U extends T, no parameter of type U
function foo<T, U extends T>(t: T) {
~~~~~~~~~~~
!!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
var u: U;
return u;
}
var r = foo(1); // ok
var r2 = foo(null); // {}
var r3 = foo(new Object()); // {}
var r4 = foo<Date, Date>(1); // error
~
!!! Argument of type 'number' is not assignable to parameter of type 'Date'.
var r5 = foo<Date, Date>(new Date()); // no error