Skip to content

Commit 118a2cc

Browse files
committed
Accept new baselines
1 parent 332861b commit 118a2cc

4 files changed

Lines changed: 489 additions & 368 deletions

File tree

tests/baselines/reference/inferTypes1.errors.txt

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
tests/cases/conformance/types/conditional/inferTypes1.ts(31,23): error TS2344: Type 'string' does not satisfy the constraint '(...args: any) => any'.
22
tests/cases/conformance/types/conditional/inferTypes1.ts(32,23): error TS2344: Type 'Function' does not satisfy the constraint '(...args: any) => any'.
33
Type 'Function' provides no match for the signature '(...args: any): any'.
4-
tests/cases/conformance/types/conditional/inferTypes1.ts(37,25): error TS2344: Type 'string' does not satisfy the constraint 'new (...args: any) => any'.
5-
tests/cases/conformance/types/conditional/inferTypes1.ts(38,25): error TS2344: Type 'Function' does not satisfy the constraint 'new (...args: any) => any'.
4+
tests/cases/conformance/types/conditional/inferTypes1.ts(38,25): error TS2344: Type 'string' does not satisfy the constraint 'new (...args: any) => any'.
5+
tests/cases/conformance/types/conditional/inferTypes1.ts(39,25): error TS2344: Type 'Function' does not satisfy the constraint 'new (...args: any) => any'.
66
Type 'Function' provides no match for the signature 'new (...args: any): any'.
7-
tests/cases/conformance/types/conditional/inferTypes1.ts(46,25): error TS2344: Type '(x: string, y: string) => number' does not satisfy the constraint '(x: any) => any'.
8-
tests/cases/conformance/types/conditional/inferTypes1.ts(47,25): error TS2344: Type 'Function' does not satisfy the constraint '(x: any) => any'.
7+
tests/cases/conformance/types/conditional/inferTypes1.ts(47,25): error TS2344: Type '(x: string, y: string) => number' does not satisfy the constraint '(x: any) => any'.
8+
tests/cases/conformance/types/conditional/inferTypes1.ts(48,25): error TS2344: Type 'Function' does not satisfy the constraint '(x: any) => any'.
99
Type 'Function' provides no match for the signature '(x: any): any'.
10-
tests/cases/conformance/types/conditional/inferTypes1.ts(73,12): error TS1338: 'infer' declarations are only permitted in the 'extends' clause of a conditional type.
11-
tests/cases/conformance/types/conditional/inferTypes1.ts(74,15): error TS1338: 'infer' declarations are only permitted in the 'extends' clause of a conditional type.
12-
tests/cases/conformance/types/conditional/inferTypes1.ts(74,41): error TS1338: 'infer' declarations are only permitted in the 'extends' clause of a conditional type.
13-
tests/cases/conformance/types/conditional/inferTypes1.ts(74,51): error TS1338: 'infer' declarations are only permitted in the 'extends' clause of a conditional type.
14-
tests/cases/conformance/types/conditional/inferTypes1.ts(75,15): error TS2304: Cannot find name 'U'.
15-
tests/cases/conformance/types/conditional/inferTypes1.ts(75,15): error TS4081: Exported type alias 'T62' has or is using private name 'U'.
16-
tests/cases/conformance/types/conditional/inferTypes1.ts(75,43): error TS2304: Cannot find name 'U'.
17-
tests/cases/conformance/types/conditional/inferTypes1.ts(75,43): error TS4081: Exported type alias 'T62' has or is using private name 'U'.
18-
tests/cases/conformance/types/conditional/inferTypes1.ts(82,44): error TS2344: Type 'U' does not satisfy the constraint 'string'.
10+
tests/cases/conformance/types/conditional/inferTypes1.ts(74,12): error TS1338: 'infer' declarations are only permitted in the 'extends' clause of a conditional type.
11+
tests/cases/conformance/types/conditional/inferTypes1.ts(75,15): error TS1338: 'infer' declarations are only permitted in the 'extends' clause of a conditional type.
12+
tests/cases/conformance/types/conditional/inferTypes1.ts(75,41): error TS1338: 'infer' declarations are only permitted in the 'extends' clause of a conditional type.
13+
tests/cases/conformance/types/conditional/inferTypes1.ts(75,51): error TS1338: 'infer' declarations are only permitted in the 'extends' clause of a conditional type.
14+
tests/cases/conformance/types/conditional/inferTypes1.ts(76,15): error TS2304: Cannot find name 'U'.
15+
tests/cases/conformance/types/conditional/inferTypes1.ts(76,15): error TS4081: Exported type alias 'T62' has or is using private name 'U'.
16+
tests/cases/conformance/types/conditional/inferTypes1.ts(76,43): error TS2304: Cannot find name 'U'.
17+
tests/cases/conformance/types/conditional/inferTypes1.ts(76,43): error TS4081: Exported type alias 'T62' has or is using private name 'U'.
18+
tests/cases/conformance/types/conditional/inferTypes1.ts(83,44): error TS2344: Type 'U' does not satisfy the constraint 'string'.
1919
Type 'number' is not assignable to type 'string'.
20-
tests/cases/conformance/types/conditional/inferTypes1.ts(144,40): error TS2322: Type 'T' is not assignable to type 'string | number | symbol'.
20+
tests/cases/conformance/types/conditional/inferTypes1.ts(145,40): error TS2322: Type 'T' is not assignable to type 'string | number | symbol'.
2121
Type 'T' is not assignable to type 'symbol'.
2222

2323

@@ -59,6 +59,7 @@ tests/cases/conformance/types/conditional/inferTypes1.ts(144,40): error TS2322:
5959
~~~~~~~~
6060
!!! error TS2344: Type 'Function' does not satisfy the constraint '(...args: any) => any'.
6161
!!! error TS2344: Type 'Function' provides no match for the signature '(...args: any): any'.
62+
type T19<T extends any[]> = ReturnType<(x: string, ...args: T) => T[]>; // T[]
6263

6364
type U10 = InstanceType<typeof C>; // C
6465
type U11 = InstanceType<any>; // any
@@ -226,4 +227,14 @@ tests/cases/conformance/types/conditional/inferTypes1.ts(144,40): error TS2322:
226227

227228
type Test1 = EnsureIsString<"hello">; // "hello"
228229
type Test2 = EnsureIsString<42>; // never
230+
231+
// Repros from #26856
232+
233+
function invoker <K extends string | number | symbol, A extends any[]> (key: K, ...args: A) {
234+
return <T extends Record<K, (...args: A) => any>> (obj: T): ReturnType<T[K]> => obj[key](...args)
235+
}
236+
237+
const result = invoker('test', true)({ test: (a: boolean) => 123 })
238+
239+
type Foo2<A extends any[]> = ReturnType<(...args: A) => string>;
229240

tests/baselines/reference/inferTypes1.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type T15 = ReturnType<any>; // any
3131
type T16 = ReturnType<never>; // never
3232
type T17 = ReturnType<string>; // Error
3333
type T18 = ReturnType<Function>; // Error
34+
type T19<T extends any[]> = ReturnType<(x: string, ...args: T) => T[]>; // T[]
3435

3536
type U10 = InstanceType<typeof C>; // C
3637
type U11 = InstanceType<any>; // any
@@ -166,6 +167,16 @@ type EnsureIsString<T> = T extends MustBeString<infer U> ? U : never;
166167

167168
type Test1 = EnsureIsString<"hello">; // "hello"
168169
type Test2 = EnsureIsString<42>; // never
170+
171+
// Repros from #26856
172+
173+
function invoker <K extends string | number | symbol, A extends any[]> (key: K, ...args: A) {
174+
return <T extends Record<K, (...args: A) => any>> (obj: T): ReturnType<T[K]> => obj[key](...args)
175+
}
176+
177+
const result = invoker('test', true)({ test: (a: boolean) => 123 })
178+
179+
type Foo2<A extends any[]> = ReturnType<(...args: A) => string>;
169180

170181

171182
//// [inferTypes1.js]
@@ -182,3 +193,12 @@ var C = /** @class */ (function () {
182193
}());
183194
var z1 = ex.customClass;
184195
var z2 = ex.obj.nested.attr;
196+
// Repros from #26856
197+
function invoker(key) {
198+
var args = [];
199+
for (var _i = 1; _i < arguments.length; _i++) {
200+
args[_i - 1] = arguments[_i];
201+
}
202+
return function (obj) { return obj[key].apply(obj, args); };
203+
}
204+
var result = invoker('test', true)({ test: function (a) { return 123; } });

0 commit comments

Comments
 (0)