File: strictBindCallApply1.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 (279 lines) | stat: -rw-r--r-- 21,031 bytes parent folder | download | duplicates (3)
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
tests/cases/conformance/functions/strictBindCallApply1.ts(11,11): error TS2769: No overload matches this call.
  Overload 1 of 6, '(this: (this: undefined, arg0: 10, arg1: string) => string, thisArg: undefined, arg0: 10, arg1: string): () => string', gave the following error.
    Argument of type 'number' is not assignable to parameter of type 'string'.
  Overload 2 of 6, '(this: (this: undefined, ...args: (10 | 20)[]) => string, thisArg: undefined, ...args: (10 | 20)[]): (...args: (10 | 20)[]) => string', gave the following error.
    The 'this' context of type '(a: number, b: string) => string' is not assignable to method's 'this' of type '(this: undefined, ...args: (10 | 20)[]) => string'.
      Types of parameters 'b' and 'args' are incompatible.
        Type 'number' is not assignable to type 'string'.
          Type 'number' is not assignable to type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(17,15): error TS2554: Expected 3 arguments, but got 2.
tests/cases/conformance/functions/strictBindCallApply1.ts(18,35): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(19,44): error TS2554: Expected 3 arguments, but got 4.
tests/cases/conformance/functions/strictBindCallApply1.ts(22,32): error TS2345: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'.
  Source has 1 element(s) but target requires 2.
tests/cases/conformance/functions/strictBindCallApply1.ts(23,37): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(24,32): error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'.
  Source has 3 element(s) but target allows only 2.
tests/cases/conformance/functions/strictBindCallApply1.ts(41,11): error TS2769: No overload matches this call.
  Overload 1 of 6, '(this: (this: C, arg0: 10, arg1: string) => string, thisArg: C, arg0: 10, arg1: string): () => string', gave the following error.
    Argument of type 'number' is not assignable to parameter of type 'string'.
  Overload 2 of 6, '(this: (this: C, ...args: (10 | 20)[]) => string, thisArg: C, ...args: (10 | 20)[]): (...args: (10 | 20)[]) => string', gave the following error.
    The 'this' context of type '(this: C, a: number, b: string) => string' is not assignable to method's 'this' of type '(this: C, ...args: (10 | 20)[]) => string'.
      Types of parameters 'b' and 'args' are incompatible.
        Type 'number' is not assignable to type 'string'.
          Type 'number' is not assignable to type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(42,11): error TS2769: No overload matches this call.
  Overload 1 of 6, '(this: (this: C, a: number, b: string) => string, thisArg: C): (a: number, b: string) => string', gave the following error.
    Argument of type 'undefined' is not assignable to parameter of type 'C'.
  Overload 2 of 6, '(this: (this: C, ...args: (string | number)[]) => string, thisArg: C, ...args: (string | number)[]): (...args: (string | number)[]) => string', gave the following error.
    The 'this' context of type '(this: C, a: number, b: string) => string' is not assignable to method's 'this' of type '(this: C, ...args: (string | number)[]) => string'.
      Types of parameters 'a' and 'args' are incompatible.
        Type 'string | number' is not assignable to type 'number'.
          Type 'string' is not assignable to type 'number'.
tests/cases/conformance/functions/strictBindCallApply1.ts(48,17): error TS2554: Expected 3 arguments, but got 2.
tests/cases/conformance/functions/strictBindCallApply1.ts(49,29): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(50,38): error TS2554: Expected 3 arguments, but got 4.
tests/cases/conformance/functions/strictBindCallApply1.ts(51,22): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'.
tests/cases/conformance/functions/strictBindCallApply1.ts(54,26): error TS2345: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'.
  Source has 1 element(s) but target requires 2.
tests/cases/conformance/functions/strictBindCallApply1.ts(55,31): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(56,26): error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'.
  Source has 3 element(s) but target allows only 2.
tests/cases/conformance/functions/strictBindCallApply1.ts(57,23): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'.
tests/cases/conformance/functions/strictBindCallApply1.ts(62,11): error TS2769: No overload matches this call.
  Overload 1 of 6, '(this: new (arg0: 10, arg1: string) => C, thisArg: any, arg0: 10, arg1: string): new () => C', gave the following error.
    Argument of type 'number' is not assignable to parameter of type 'string'.
  Overload 2 of 6, '(this: new (...args: (10 | 20)[]) => C, thisArg: any, ...args: (10 | 20)[]): new (...args: (10 | 20)[]) => C', gave the following error.
    The 'this' context of type 'typeof C' is not assignable to method's 'this' of type 'new (...args: (10 | 20)[]) => C'.
      Types of construct signatures are incompatible.
        Type 'new (a: number, b: string) => C' is not assignable to type 'new (...args: (10 | 20)[]) => C'.
          Types of parameters 'b' and 'args' are incompatible.
            Type 'number' is not assignable to type 'string'.
              Type 'number' is not assignable to type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(65,3): error TS2554: Expected 3 arguments, but got 2.
tests/cases/conformance/functions/strictBindCallApply1.ts(66,15): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(67,24): error TS2554: Expected 3 arguments, but got 4.
tests/cases/conformance/functions/strictBindCallApply1.ts(70,12): error TS2345: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'.
  Source has 1 element(s) but target requires 2.
tests/cases/conformance/functions/strictBindCallApply1.ts(71,17): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(72,12): error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'.
  Source has 3 element(s) but target allows only 2.
tests/cases/conformance/functions/strictBindCallApply1.ts(76,5): error TS2769: No overload matches this call.
  Overload 1 of 6, '(this: (this: 1, ...args: T) => void, thisArg: 1): (...args: T) => void', gave the following error.
    Argument of type '2' is not assignable to parameter of type '1'.
  Overload 2 of 6, '(this: (this: 1, ...args: unknown[]) => void, thisArg: 1, ...args: unknown[]): (...args: unknown[]) => void', gave the following error.
    The 'this' context of type '(this: 1, ...args: T) => void' is not assignable to method's 'this' of type '(this: 1, ...args: unknown[]) => void'.
      Types of parameters 'args' and 'args' are incompatible.
        Type 'unknown[]' is not assignable to type 'T'.
          'unknown[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'unknown[]'.
tests/cases/conformance/functions/strictBindCallApply1.ts(81,5): error TS2769: No overload matches this call.
  Overload 1 of 6, '(this: (this: 1, ...args: T extends 1 ? [unknown] : [unknown, unknown]) => void, thisArg: 1): (...args: T extends 1 ? [unknown] : [unknown, unknown]) => void', gave the following error.
    Argument of type '2' is not assignable to parameter of type '1'.
  Overload 2 of 6, '(this: (this: 1, ...args: unknown[]) => void, thisArg: 1, ...args: unknown[]): (...args: unknown[]) => void', gave the following error.
    The 'this' context of type '(this: 1, ...args: T extends 1 ? [unknown] : [unknown, unknown]) => void' is not assignable to method's 'this' of type '(this: 1, ...args: unknown[]) => void'.
      Types of parameters 'args' and 'args' are incompatible.
        Type 'unknown[]' is not assignable to type 'T extends 1 ? [unknown] : [unknown, unknown]'.


==== tests/cases/conformance/functions/strictBindCallApply1.ts (26 errors) ====
    declare function foo(a: number, b: string): string;
    
    declare function overloaded(s: string): number;
    declare function overloaded(n: number): string;
    
    declare function generic<T>(x: T): T;
    
    let f00 = foo.bind(undefined);
    let f01 = foo.bind(undefined, 10);
    let f02 = foo.bind(undefined, 10, "hello");
    let f03 = foo.bind(undefined, 10, 20);  // Error
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2769: No overload matches this call.
!!! error TS2769:   Overload 1 of 6, '(this: (this: undefined, arg0: 10, arg1: string) => string, thisArg: undefined, arg0: 10, arg1: string): () => string', gave the following error.
!!! error TS2769:     Argument of type 'number' is not assignable to parameter of type 'string'.
!!! error TS2769:   Overload 2 of 6, '(this: (this: undefined, ...args: (10 | 20)[]) => string, thisArg: undefined, ...args: (10 | 20)[]): (...args: (10 | 20)[]) => string', gave the following error.
!!! error TS2769:     The 'this' context of type '(a: number, b: string) => string' is not assignable to method's 'this' of type '(this: undefined, ...args: (10 | 20)[]) => string'.
!!! error TS2769:       Types of parameters 'b' and 'args' are incompatible.
!!! error TS2769:         Type 'number' is not assignable to type 'string'.
!!! error TS2769:           Type 'number' is not assignable to type 'string'.
    
    let f04 = overloaded.bind(undefined);  // typeof overloaded
    let f05 = generic.bind(undefined);  // typeof generic
    
    let c00 = foo.call(undefined, 10, "hello");
    let c01 = foo.call(undefined, 10);  // Error
                  ~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 3 arguments, but got 2.
    let c02 = foo.call(undefined, 10, 20);  // Error
                                      ~~
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
    let c03 = foo.call(undefined, 10, "hello", 30);  // Error
                                               ~~
!!! error TS2554: Expected 3 arguments, but got 4.
    
    let a00 = foo.apply(undefined, [10, "hello"]);
    let a01 = foo.apply(undefined, [10]);  // Error
                                   ~~~~
!!! error TS2345: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'.
!!! error TS2345:   Source has 1 element(s) but target requires 2.
    let a02 = foo.apply(undefined, [10, 20]);  // Error
                                        ~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
    let a03 = foo.apply(undefined, [10, "hello", 30]);  // Error
                                   ~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'.
!!! error TS2345:   Source has 3 element(s) but target allows only 2.
    
    class C {
        constructor(a: number, b: string) {}
        foo(this: this, a: number, b: string): string { return "" }
        overloaded(s: string): number;
        overloaded(n: number): string;
        overloaded(x: any): any { return <any>undefined }
        generic<T>(x: T): T { return x }
    }
    
    declare let c: C;
    declare let obj: {};
    
    let f10 = c.foo.bind(c);
    let f11 = c.foo.bind(c, 10);
    let f12 = c.foo.bind(c, 10, "hello");
    let f13 = c.foo.bind(c, 10, 20);  // Error
              ~~~~~~~~~~~~~~~~~~~~~
!!! error TS2769: No overload matches this call.
!!! error TS2769:   Overload 1 of 6, '(this: (this: C, arg0: 10, arg1: string) => string, thisArg: C, arg0: 10, arg1: string): () => string', gave the following error.
!!! error TS2769:     Argument of type 'number' is not assignable to parameter of type 'string'.
!!! error TS2769:   Overload 2 of 6, '(this: (this: C, ...args: (10 | 20)[]) => string, thisArg: C, ...args: (10 | 20)[]): (...args: (10 | 20)[]) => string', gave the following error.
!!! error TS2769:     The 'this' context of type '(this: C, a: number, b: string) => string' is not assignable to method's 'this' of type '(this: C, ...args: (10 | 20)[]) => string'.
!!! error TS2769:       Types of parameters 'b' and 'args' are incompatible.
!!! error TS2769:         Type 'number' is not assignable to type 'string'.
!!! error TS2769:           Type 'number' is not assignable to type 'string'.
    let f14 = c.foo.bind(undefined);  // Error
              ~~~~~~~~~~~~~~~~~~~~~
!!! error TS2769: No overload matches this call.
!!! error TS2769:   Overload 1 of 6, '(this: (this: C, a: number, b: string) => string, thisArg: C): (a: number, b: string) => string', gave the following error.
!!! error TS2769:     Argument of type 'undefined' is not assignable to parameter of type 'C'.
!!! error TS2769:   Overload 2 of 6, '(this: (this: C, ...args: (string | number)[]) => string, thisArg: C, ...args: (string | number)[]): (...args: (string | number)[]) => string', gave the following error.
!!! error TS2769:     The 'this' context of type '(this: C, a: number, b: string) => string' is not assignable to method's 'this' of type '(this: C, ...args: (string | number)[]) => string'.
!!! error TS2769:       Types of parameters 'a' and 'args' are incompatible.
!!! error TS2769:         Type 'string | number' is not assignable to type 'number'.
!!! error TS2769:           Type 'string' is not assignable to type 'number'.
    
    let f15 = c.overloaded.bind(c);  // typeof C.prototype.overloaded
    let f16 = c.generic.bind(c);  // typeof C.prototype.generic
    
    let c10 = c.foo.call(c, 10, "hello");
    let c11 = c.foo.call(c, 10);  // Error
                    ~~~~~~~~~~~
!!! error TS2554: Expected 3 arguments, but got 2.
    let c12 = c.foo.call(c, 10, 20);  // Error
                                ~~
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
    let c13 = c.foo.call(c, 10, "hello", 30);  // Error
                                         ~~
!!! error TS2554: Expected 3 arguments, but got 4.
    let c14 = c.foo.call(undefined, 10, "hello");  // Error
                         ~~~~~~~~~
!!! error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'.
    
    let a10 = c.foo.apply(c, [10, "hello"]);
    let a11 = c.foo.apply(c, [10]);  // Error
                             ~~~~
!!! error TS2345: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'.
!!! error TS2345:   Source has 1 element(s) but target requires 2.
    let a12 = c.foo.apply(c, [10, 20]);  // Error
                                  ~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
    let a13 = c.foo.apply(c, [10, "hello", 30]);  // Error
                             ~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'.
!!! error TS2345:   Source has 3 element(s) but target allows only 2.
    let a14 = c.foo.apply(undefined, [10, "hello"]);  // Error
                          ~~~~~~~~~
!!! error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'.
    
    let f20 = C.bind(undefined);
    let f21 = C.bind(undefined, 10);
    let f22 = C.bind(undefined, 10, "hello");
    let f23 = C.bind(undefined, 10, 20);  // Error
              ~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2769: No overload matches this call.
!!! error TS2769:   Overload 1 of 6, '(this: new (arg0: 10, arg1: string) => C, thisArg: any, arg0: 10, arg1: string): new () => C', gave the following error.
!!! error TS2769:     Argument of type 'number' is not assignable to parameter of type 'string'.
!!! error TS2769:   Overload 2 of 6, '(this: new (...args: (10 | 20)[]) => C, thisArg: any, ...args: (10 | 20)[]): new (...args: (10 | 20)[]) => C', gave the following error.
!!! error TS2769:     The 'this' context of type 'typeof C' is not assignable to method's 'this' of type 'new (...args: (10 | 20)[]) => C'.
!!! error TS2769:       Types of construct signatures are incompatible.
!!! error TS2769:         Type 'new (a: number, b: string) => C' is not assignable to type 'new (...args: (10 | 20)[]) => C'.
!!! error TS2769:           Types of parameters 'b' and 'args' are incompatible.
!!! error TS2769:             Type 'number' is not assignable to type 'string'.
!!! error TS2769:               Type 'number' is not assignable to type 'string'.
    
    C.call(c, 10, "hello");
    C.call(c, 10);  // Error
      ~~~~~~~~~~~
!!! error TS2554: Expected 3 arguments, but got 2.
    C.call(c, 10, 20);  // Error
                  ~~
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
    C.call(c, 10, "hello", 30);  // Error
                           ~~
!!! error TS2554: Expected 3 arguments, but got 4.
    
    C.apply(c, [10, "hello"]);
    C.apply(c, [10]);  // Error
               ~~~~
!!! error TS2345: Argument of type '[number]' is not assignable to parameter of type '[a: number, b: string]'.
!!! error TS2345:   Source has 1 element(s) but target requires 2.
    C.apply(c, [10, 20]);  // Error
                    ~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
    C.apply(c, [10, "hello", 30]);  // Error
               ~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[a: number, b: string]'.
!!! error TS2345:   Source has 3 element(s) but target allows only 2.
    
    function bar<T extends unknown[]>(callback: (this: 1, ...args: T) => void) {
        callback.bind(1);
        callback.bind(2); // Error
        ~~~~~~~~~~~~~~~~
!!! error TS2769: No overload matches this call.
!!! error TS2769:   Overload 1 of 6, '(this: (this: 1, ...args: T) => void, thisArg: 1): (...args: T) => void', gave the following error.
!!! error TS2769:     Argument of type '2' is not assignable to parameter of type '1'.
!!! error TS2769:   Overload 2 of 6, '(this: (this: 1, ...args: unknown[]) => void, thisArg: 1, ...args: unknown[]): (...args: unknown[]) => void', gave the following error.
!!! error TS2769:     The 'this' context of type '(this: 1, ...args: T) => void' is not assignable to method's 'this' of type '(this: 1, ...args: unknown[]) => void'.
!!! error TS2769:       Types of parameters 'args' and 'args' are incompatible.
!!! error TS2769:         Type 'unknown[]' is not assignable to type 'T'.
!!! error TS2769:           'unknown[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'unknown[]'.
    }
    
    function baz<T extends 1 | 2>(callback: (this: 1, ...args: T extends 1 ? [unknown] : [unknown, unknown]) => void) {
        callback.bind(1);
        callback.bind(2); // Error
        ~~~~~~~~~~~~~~~~
!!! error TS2769: No overload matches this call.
!!! error TS2769:   Overload 1 of 6, '(this: (this: 1, ...args: T extends 1 ? [unknown] : [unknown, unknown]) => void, thisArg: 1): (...args: T extends 1 ? [unknown] : [unknown, unknown]) => void', gave the following error.
!!! error TS2769:     Argument of type '2' is not assignable to parameter of type '1'.
!!! error TS2769:   Overload 2 of 6, '(this: (this: 1, ...args: unknown[]) => void, thisArg: 1, ...args: unknown[]): (...args: unknown[]) => void', gave the following error.
!!! error TS2769:     The 'this' context of type '(this: 1, ...args: T extends 1 ? [unknown] : [unknown, unknown]) => void' is not assignable to method's 'this' of type '(this: 1, ...args: unknown[]) => void'.
!!! error TS2769:       Types of parameters 'args' and 'args' are incompatible.
!!! error TS2769:         Type 'unknown[]' is not assignable to type 'T extends 1 ? [unknown] : [unknown, unknown]'.
    }
    
    // Repro from #32964
    class Foo<T extends unknown[]> {
        constructor() {
            this.fn.bind(this);
        }
    
        fn(...args: T): void {}
    }
    
    class Bar<T extends 1 | 2> {
        constructor() {
            this.fn.bind(this);
        }
    
        fn(...args: T extends 1 ? [unknown] : [unknown, unknown]) {}
    }