|
1 | | -tests/cases/conformance/types/conditional/inferTypes1.ts(31,23): error TS2344: Type 'string' does not satisfy the constraint '(...args: any[]) => any'. |
2 | | -tests/cases/conformance/types/conditional/inferTypes1.ts(32,23): error TS2344: Type 'Function' does not satisfy the constraint '(...args: any[]) => any'. |
3 | | - 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'. |
6 | | - 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'. |
| 1 | +tests/cases/conformance/types/conditional/inferTypes1.ts(31,23): error TS2344: Type 'string' does not satisfy the constraint '(...args: any) => any'. |
| 2 | +tests/cases/conformance/types/conditional/inferTypes1.ts(32,23): error TS2344: Type 'Function' does not satisfy the constraint '(...args: any) => any'. |
| 3 | + Type 'Function' provides no match for the signature '(...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'. |
| 6 | + Type 'Function' provides no match for the signature 'new (...args: 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'. |
9 | 9 | 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'. |
19 | 19 | 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'. |
21 | 21 | Type 'T' is not assignable to type 'symbol'. |
22 | 22 |
|
23 | 23 |
|
@@ -54,22 +54,23 @@ tests/cases/conformance/types/conditional/inferTypes1.ts(144,40): error TS2322: |
54 | 54 | type T16 = ReturnType<never>; // never |
55 | 55 | type T17 = ReturnType<string>; // Error |
56 | 56 | ~~~~~~ |
57 | | -!!! error TS2344: Type 'string' does not satisfy the constraint '(...args: any[]) => any'. |
| 57 | +!!! error TS2344: Type 'string' does not satisfy the constraint '(...args: any) => any'. |
58 | 58 | type T18 = ReturnType<Function>; // Error |
59 | 59 | ~~~~~~~~ |
60 | | -!!! error TS2344: Type 'Function' does not satisfy the constraint '(...args: any[]) => any'. |
61 | | -!!! error TS2344: Type 'Function' provides no match for the signature '(...args: any[]): any'. |
| 60 | +!!! error TS2344: Type 'Function' does not satisfy the constraint '(...args: any) => any'. |
| 61 | +!!! 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[] |
62 | 63 |
|
63 | 64 | type U10 = InstanceType<typeof C>; // C |
64 | 65 | type U11 = InstanceType<any>; // any |
65 | 66 | type U12 = InstanceType<never>; // never |
66 | 67 | type U13 = InstanceType<string>; // Error |
67 | 68 | ~~~~~~ |
68 | | -!!! error TS2344: Type 'string' does not satisfy the constraint 'new (...args: any[]) => any'. |
| 69 | +!!! error TS2344: Type 'string' does not satisfy the constraint 'new (...args: any) => any'. |
69 | 70 | type U14 = InstanceType<Function>; // Error |
70 | 71 | ~~~~~~~~ |
71 | | -!!! error TS2344: Type 'Function' does not satisfy the constraint 'new (...args: any[]) => any'. |
72 | | -!!! error TS2344: Type 'Function' provides no match for the signature 'new (...args: any[]): any'. |
| 72 | +!!! error TS2344: Type 'Function' does not satisfy the constraint 'new (...args: any) => any'. |
| 73 | +!!! error TS2344: Type 'Function' provides no match for the signature 'new (...args: any): any'. |
73 | 74 |
|
74 | 75 | type ArgumentType<T extends (x: any) => any> = T extends (a: infer A) => any ? A : any; |
75 | 76 |
|
@@ -226,4 +227,14 @@ tests/cases/conformance/types/conditional/inferTypes1.ts(144,40): error TS2322: |
226 | 227 |
|
227 | 228 | type Test1 = EnsureIsString<"hello">; // "hello" |
228 | 229 | 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>; |
229 | 240 |
|
0 commit comments