File: overloadresolutionWithConstraintCheckingDeferred.errors.txt

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (112 lines) | stat: -rw-r--r-- 8,198 bytes parent folder | download | duplicates (4)
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
105
106
107
108
109
110
111
112
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(14,22): error TS2769: No overload matches this call.
  Overload 1 of 3, '(arg: (x: D) => number): string', gave the following error.
    Type 'G<A>' is not assignable to type 'number'.
  Overload 2 of 3, '(arg: (x: C) => any): string', gave the following error.
    Argument of type '(x: D) => G<A>' is not assignable to parameter of type '(x: C) => any'.
      Types of parameters 'x' and 'x' are incompatible.
        Property 'q' is missing in type 'C' but required in type 'D'.
  Overload 3 of 3, '(arg: (x: B) => any): number', gave the following error.
    Argument of type '(x: D) => G<A>' is not assignable to parameter of type '(x: B) => any'.
      Types of parameters 'x' and 'x' are incompatible.
        Property 'q' is missing in type 'B' but required in type 'D'.
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(14,37): error TS2345: Argument of type 'D' is not assignable to parameter of type 'A'.
  Property 'x' is missing in type 'D' but required in type 'A'.
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(16,23): error TS2769: No overload matches this call.
  Overload 1 of 3, '(arg: (x: D) => number): string', gave the following error.
    Type 'G<D>' is not assignable to type 'number'.
  Overload 2 of 3, '(arg: (x: C) => any): string', gave the following error.
    Argument of type '(x: D) => G<D>' is not assignable to parameter of type '(x: C) => any'.
      Types of parameters 'x' and 'x' are incompatible.
        Type 'C' is not assignable to type 'D'.
  Overload 3 of 3, '(arg: (x: B) => any): number', gave the following error.
    Argument of type '(x: D) => G<D>' is not assignable to parameter of type '(x: B) => any'.
      Types of parameters 'x' and 'x' are incompatible.
        Type 'B' is not assignable to type 'D'.
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(16,38): error TS2344: Type 'D' does not satisfy the constraint 'A'.
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(18,27): error TS2769: No overload matches this call.
  Overload 1 of 3, '(arg: (x: D) => number): string', gave the following error.
    Argument of type '(x: D) => G<D>' is not assignable to parameter of type '(x: D) => number'.
      Type 'G<D>' is not assignable to type 'number'.
  Overload 2 of 3, '(arg: (x: C) => any): string', gave the following error.
    Argument of type '(x: D) => G<D>' is not assignable to parameter of type '(x: C) => any'.
      Types of parameters 'x' and 'x' are incompatible.
        Type 'C' is not assignable to type 'D'.
  Overload 3 of 3, '(arg: (x: B) => any): number', gave the following error.
    Argument of type '(x: D) => G<D>' is not assignable to parameter of type '(x: B) => any'.
      Types of parameters 'x' and 'x' are incompatible.
        Type 'B' is not assignable to type 'D'.
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(19,14): error TS2344: Type 'D' does not satisfy the constraint 'A'.


==== tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts (6 errors) ====
    interface A { x }
    interface B { x; y }
    interface C { z }
    interface D { q }
    
    class G<T extends A> {
        constructor(x: T) { }
    }
    
    declare function foo(arg: (x: D) => number): string;
    declare function foo(arg: (x: C) => any): string;
    declare function foo(arg: (x: B) => any): number;
    
    var result: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked.
                         ~~~~~~~~~~~~~~~~~~
!!! error TS2769: No overload matches this call.
!!! error TS2769:   Overload 1 of 3, '(arg: (x: D) => number): string', gave the following error.
!!! error TS2769:     Type 'G<A>' is not assignable to type 'number'.
!!! error TS2769:   Overload 2 of 3, '(arg: (x: C) => any): string', gave the following error.
!!! error TS2769:     Argument of type '(x: D) => G<A>' is not assignable to parameter of type '(x: C) => any'.
!!! error TS2769:       Types of parameters 'x' and 'x' are incompatible.
!!! error TS2769:         Property 'q' is missing in type 'C' but required in type 'D'.
!!! error TS2769:   Overload 3 of 3, '(arg: (x: B) => any): number', gave the following error.
!!! error TS2769:     Argument of type '(x: D) => G<A>' is not assignable to parameter of type '(x: B) => any'.
!!! error TS2769:       Types of parameters 'x' and 'x' are incompatible.
!!! error TS2769:         Property 'q' is missing in type 'B' but required in type 'D'.
!!! related TS6502 tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts:10:27: The expected type comes from the return type of this signature.
!!! related TS2728 tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts:4:15: 'q' is declared here.
!!! related TS2728 tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts:4:15: 'q' is declared here.
                                        ~
!!! error TS2345: Argument of type 'D' is not assignable to parameter of type 'A'.
!!! error TS2345:   Property 'x' is missing in type 'D' but required in type 'A'.
!!! related TS2728 tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts:1:15: 'x' is declared here.
    
    var result2: number = foo(x => new G<typeof x>(x)); // x has type D, new G(x) fails, so first overload is picked.
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2769: No overload matches this call.
!!! error TS2769:   Overload 1 of 3, '(arg: (x: D) => number): string', gave the following error.
!!! error TS2769:     Type 'G<D>' is not assignable to type 'number'.
!!! error TS2769:   Overload 2 of 3, '(arg: (x: C) => any): string', gave the following error.
!!! error TS2769:     Argument of type '(x: D) => G<D>' is not assignable to parameter of type '(x: C) => any'.
!!! error TS2769:       Types of parameters 'x' and 'x' are incompatible.
!!! error TS2769:         Type 'C' is not assignable to type 'D'.
!!! error TS2769:   Overload 3 of 3, '(arg: (x: B) => any): number', gave the following error.
!!! error TS2769:     Argument of type '(x: D) => G<D>' is not assignable to parameter of type '(x: B) => any'.
!!! error TS2769:       Types of parameters 'x' and 'x' are incompatible.
!!! error TS2769:         Type 'B' is not assignable to type 'D'.
!!! related TS6502 tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts:10:27: The expected type comes from the return type of this signature.
                                         ~~~~~~~~
!!! error TS2344: Type 'D' does not satisfy the constraint 'A'.
    
    var result3: string = foo(x => { // x has type D
                              ~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2769: No overload matches this call.
!!! error TS2769:   Overload 1 of 3, '(arg: (x: D) => number): string', gave the following error.
!!! error TS2769:     Argument of type '(x: D) => G<D>' is not assignable to parameter of type '(x: D) => number'.
!!! error TS2769:       Type 'G<D>' is not assignable to type 'number'.
!!! error TS2769:   Overload 2 of 3, '(arg: (x: C) => any): string', gave the following error.
!!! error TS2769:     Argument of type '(x: D) => G<D>' is not assignable to parameter of type '(x: C) => any'.
!!! error TS2769:       Types of parameters 'x' and 'x' are incompatible.
!!! error TS2769:         Type 'C' is not assignable to type 'D'.
!!! error TS2769:   Overload 3 of 3, '(arg: (x: B) => any): number', gave the following error.
!!! error TS2769:     Argument of type '(x: D) => G<D>' is not assignable to parameter of type '(x: B) => any'.
!!! error TS2769:       Types of parameters 'x' and 'x' are incompatible.
!!! error TS2769:         Type 'B' is not assignable to type 'D'.
        var y: G<typeof x>; // error that D does not satisfy constraint, y is of type G<D>, entire call to foo is an error
                 ~~~~~~~~
!!! error TS2344: Type 'D' does not satisfy the constraint 'A'.
        return y;
    });