1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithConstraintsTypeArgumentInference2.ts(11,26): error TS2345: Argument of type 'number' is not assignable to parameter of type 'Date'.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithConstraintsTypeArgumentInference2.ts (1 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) {
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
~
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'Date'.
var r5 = foo<Date, Date>(new Date()); // no error
|