File: functionConstraintSatisfaction2.errors.txt

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (104 lines) | stat: -rw-r--r-- 7,237 bytes parent folder | download
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(5,5): error TS2345: Argument of type '1' is not assignable to parameter of type 'Function'.
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(6,1): error TS2554: Expected 1 arguments, but got 2.
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(7,1): error TS2554: Expected 1 arguments, but got 2.
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(23,14): error TS2345: Argument of type 'Function' is not assignable to parameter of type '(x: string) => string'.
  Type 'Function' provides no match for the signature '(x: string): string'.
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(24,15): error TS2345: Argument of type '(x: string[]) => string[]' is not assignable to parameter of type '(x: string) => string'.
  Types of parameters 'x' and 'x' are incompatible.
    Type 'string' is not assignable to type 'string[]'.
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(25,15): error TS2345: Argument of type 'typeof C' is not assignable to parameter of type '(x: string) => string'.
  Type 'typeof C' provides no match for the signature '(x: string): string'.
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(26,15): error TS2345: Argument of type 'new (x: string) => string' is not assignable to parameter of type '(x: string) => string'.
  Type 'new (x: string) => string' provides no match for the signature '(x: string): string'.
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(28,16): error TS2345: Argument of type '<U, V>(x: U, y: V) => U' is not assignable to parameter of type '(x: string) => string'.
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(29,16): error TS2345: Argument of type 'typeof C2' is not assignable to parameter of type '(x: string) => string'.
  Type 'typeof C2' provides no match for the signature '(x: string): string'.
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(30,16): error TS2345: Argument of type 'new <T>(x: T) => T' is not assignable to parameter of type '(x: string) => string'.
  Type 'new <T>(x: T) => T' provides no match for the signature '(x: string): string'.
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(34,16): error TS2345: Argument of type 'F2' is not assignable to parameter of type '(x: string) => string'.
  Type 'F2' provides no match for the signature '(x: string): string'.
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(37,10): error TS2345: Argument of type 'T' is not assignable to parameter of type '(x: string) => string'.
  Type '() => void' is not assignable to type '(x: string) => string'.
    Type 'void' is not assignable to type 'string'.
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(38,10): error TS2345: Argument of type 'U' is not assignable to parameter of type '(x: string) => string'.
  Type 'T' is not assignable to type '(x: string) => string'.


==== tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts (13 errors) ====
    // satisfaction of a constraint to Function, all of these invocations are errors unless otherwise noted
    
    function foo<T extends Function>(x: T): T { return x; }
    
    foo(1);
        ~
!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'Function'.
    foo(() => { }, 1);
    ~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1 arguments, but got 2.
    foo(1, () => { });
    ~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1 arguments, but got 2.
    
    function foo2<T extends (x: string) => string>(x: T): T { return x; }
    
    class C {
        foo: string;
    }
    
    var b: { new (x: string): string };
    
    class C2<T> {
        foo: T;
    }
    
    var b2: { new <T>(x: T): T };
    
    var r = foo2(new Function());
                 ~~~~~~~~~~~~~~
!!! error TS2345: Argument of type 'Function' is not assignable to parameter of type '(x: string) => string'.
!!! error TS2345:   Type 'Function' provides no match for the signature '(x: string): string'.
    var r2 = foo2((x: string[]) => x);
                  ~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(x: string[]) => string[]' is not assignable to parameter of type '(x: string) => string'.
!!! error TS2345:   Types of parameters 'x' and 'x' are incompatible.
!!! error TS2345:     Type 'string' is not assignable to type 'string[]'.
    var r6 = foo2(C);
                  ~
!!! error TS2345: Argument of type 'typeof C' is not assignable to parameter of type '(x: string) => string'.
!!! error TS2345:   Type 'typeof C' provides no match for the signature '(x: string): string'.
    var r7 = foo2(b);
                  ~
!!! error TS2345: Argument of type 'new (x: string) => string' is not assignable to parameter of type '(x: string) => string'.
!!! error TS2345:   Type 'new (x: string) => string' provides no match for the signature '(x: string): string'.
    var r8 = foo2(<U>(x: U) => x); // no error expected
    var r11 = foo2(<U, V>(x: U, y: V) => x);
                   ~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<U, V>(x: U, y: V) => U' is not assignable to parameter of type '(x: string) => string'.
    var r13 = foo2(C2);
                   ~~
!!! error TS2345: Argument of type 'typeof C2' is not assignable to parameter of type '(x: string) => string'.
!!! error TS2345:   Type 'typeof C2' provides no match for the signature '(x: string): string'.
    var r14 = foo2(b2);
                   ~~
!!! error TS2345: Argument of type 'new <T>(x: T) => T' is not assignable to parameter of type '(x: string) => string'.
!!! error TS2345:   Type 'new <T>(x: T) => T' provides no match for the signature '(x: string): string'.
    
    interface F2 extends Function { foo: string; }
    var f2: F2;
    var r16 = foo2(f2);
                   ~~
!!! error TS2345: Argument of type 'F2' is not assignable to parameter of type '(x: string) => string'.
!!! error TS2345:   Type 'F2' provides no match for the signature '(x: string): string'.
    
    function fff<T extends { (): void }, U extends T>(x: T, y: U) {
        foo2(x);
             ~
!!! error TS2345: Argument of type 'T' is not assignable to parameter of type '(x: string) => string'.
!!! error TS2345:   Type '() => void' is not assignable to type '(x: string) => string'.
!!! error TS2345:     Type 'void' is not assignable to type 'string'.
        foo2(y);
             ~
!!! error TS2345: Argument of type 'U' is not assignable to parameter of type '(x: string) => string'.
!!! error TS2345:   Type 'T' is not assignable to type '(x: string) => string'.
    }