File: genericCallWithConstraintsTypeArgumentInference2.errors.txt

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (18 lines) | stat: -rw-r--r-- 851 bytes parent folder | download | duplicates (4)
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