File: genericClassWithFunctionTypedMemberArguments.errors.txt

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (87 lines) | stat: -rw-r--r-- 4,941 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(57,19): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
  Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(60,19): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
  Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(61,20): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
  Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(62,19): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
  Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'string'.


==== tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts (4 errors) ====
    // Generic functions used as arguments for function typed parameters are not used to make inferences from
    // Using function arguments, no errors expected
    
    module ImmediatelyFix {
        class C<T> {
            foo<T>(x: (a: T) => T) {
                return x(null);
            }
        }
    
        var c = new C<number>();
        var r = c.foo(<U>(x: U) => ''); // {}
        var r2 = c.foo<string>(<U>(x: U) => ''); // string 
        var r3 = c.foo(x => ''); // {}
    
        class C2<T> {
            foo(x: (a: T) => T) {
                return x(null);
            }
        }
    
        var c2 = new C2<number>();
        var ra = c2.foo(<U>(x: U) => 1); // number
        var r3a = c2.foo(x => 1); // number
    }
    
    module WithCandidates {
        class C<T> {
            foo2<T, U>(x: T, cb: (a: T) => U) {
                return cb(x);
            }
        }
    
        var c: C<number>;
        var r4 = c.foo2(1, function <Z>(a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions
        var r5 = c.foo2(1, (a) => ''); // string
        var r6 = c.foo2<string, number>('', <Z>(a: Z) => 1); // number
    
        class C2<T, U> {
            foo3(x: T, cb: (a: T) => U, y: U) {
                return cb(x);
            }
        }
    
        var c2: C2<number, string>;
        var r7 = c2.foo3(1, <Z>(a: Z) => '', ''); // string
        var r8 = c2.foo3(1, function (a) { return '' }, ''); // string
    
        class C3<T, U> {
            foo3<T,U>(x: T, cb: (a: T) => U, y: U) {
                return cb(x);
            }
        }
        var c3: C3<number, string>;
    
        function other<T, U>(t: T, u: U) {
            var r10 = c.foo2(1, (x: T) => ''); // error
                      ~~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453:   Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'.
            var r10 = c.foo2(1, (x) => ''); // string
    
            var r11 = c3.foo3(1, (x: T) => '', ''); // error
                      ~~~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453:   Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'.
            var r11b = c3.foo3(1, (x: T) => '', 1); // error
                       ~~~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453:   Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'.
            var r12 = c3.foo3(1, function (a) { return '' }, 1); // error
                      ~~~~~~~
!!! error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453:   Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'string'.
        }
    }