Skip to content

Commit cf167db

Browse files
TypeScript BotAndarist
TypeScript Bot
andauthored
🤖 Pick PR #59121 (Fixed regression in signature insta...) into release-5.5 (#59204)
Co-authored-by: Mateusz BurzyÅ„ski <[email protected]>
1 parent 0d4ffed commit cf167db

File tree

5 files changed

+99
-2
lines changed

5 files changed

+99
-2
lines changed

‎src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15942,7 +15942,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1594215942
}
1594315943

1594415944
function createSignatureTypeMapper(signature: Signature, typeArguments: readonly Type[] | undefined): TypeMapper {
15945-
return createTypeMapper(signature.typeParameters!, typeArguments);
15945+
return createTypeMapper(sameMap(signature.typeParameters!, tp => tp.mapper ? instantiateType(tp, tp.mapper) : tp), typeArguments);
1594615946
}
1594715947

1594815948
function getErasedSignature(signature: Signature): Signature {

‎tests/baselines/reference/excessiveStackDepthFlatArray.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//// [tests/cases/compiler/excessiveStackDepthFlatArray.ts] ////
22

33
=== Performance Stats ===
4-
Instantiation count: 1,000
4+
Instantiation count: 1,000 -> 2,500
55

66
=== index.tsx ===
77
interface MiddlewareArray<T> extends Array<T> {}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//// [tests/cases/compiler/genericCallInferenceConditionalType1.ts] ////
2+
3+
=== genericCallInferenceConditionalType1.ts ===
4+
// https://github.com/microsoft/TypeScript/issues/59108
5+
6+
declare const f: <T>(f: (x: T) => unknown) => (x: T) => unknown;
7+
>f : Symbol(f, Decl(genericCallInferenceConditionalType1.ts, 2, 13))
8+
>T : Symbol(T, Decl(genericCallInferenceConditionalType1.ts, 2, 18))
9+
>f : Symbol(f, Decl(genericCallInferenceConditionalType1.ts, 2, 21))
10+
>x : Symbol(x, Decl(genericCallInferenceConditionalType1.ts, 2, 25))
11+
>T : Symbol(T, Decl(genericCallInferenceConditionalType1.ts, 2, 18))
12+
>x : Symbol(x, Decl(genericCallInferenceConditionalType1.ts, 2, 47))
13+
>T : Symbol(T, Decl(genericCallInferenceConditionalType1.ts, 2, 18))
14+
15+
declare const g: <T extends unknown>(x: { foo: T }) => unknown;
16+
>g : Symbol(g, Decl(genericCallInferenceConditionalType1.ts, 3, 13))
17+
>T : Symbol(T, Decl(genericCallInferenceConditionalType1.ts, 3, 18))
18+
>x : Symbol(x, Decl(genericCallInferenceConditionalType1.ts, 3, 37))
19+
>foo : Symbol(foo, Decl(genericCallInferenceConditionalType1.ts, 3, 41))
20+
>T : Symbol(T, Decl(genericCallInferenceConditionalType1.ts, 3, 18))
21+
22+
const h = f(g);
23+
>h : Symbol(h, Decl(genericCallInferenceConditionalType1.ts, 5, 5))
24+
>f : Symbol(f, Decl(genericCallInferenceConditionalType1.ts, 2, 13))
25+
>g : Symbol(g, Decl(genericCallInferenceConditionalType1.ts, 3, 13))
26+
27+
type FirstParameter<T> = T extends (x: infer P) => unknown ? P : unknown;
28+
>FirstParameter : Symbol(FirstParameter, Decl(genericCallInferenceConditionalType1.ts, 5, 15))
29+
>T : Symbol(T, Decl(genericCallInferenceConditionalType1.ts, 7, 20))
30+
>T : Symbol(T, Decl(genericCallInferenceConditionalType1.ts, 7, 20))
31+
>x : Symbol(x, Decl(genericCallInferenceConditionalType1.ts, 7, 36))
32+
>P : Symbol(P, Decl(genericCallInferenceConditionalType1.ts, 7, 44))
33+
>P : Symbol(P, Decl(genericCallInferenceConditionalType1.ts, 7, 44))
34+
35+
type X = FirstParameter<typeof h>["foo"];
36+
>X : Symbol(X, Decl(genericCallInferenceConditionalType1.ts, 7, 73))
37+
>FirstParameter : Symbol(FirstParameter, Decl(genericCallInferenceConditionalType1.ts, 5, 15))
38+
>h : Symbol(h, Decl(genericCallInferenceConditionalType1.ts, 5, 5))
39+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//// [tests/cases/compiler/genericCallInferenceConditionalType1.ts] ////
2+
3+
=== genericCallInferenceConditionalType1.ts ===
4+
// https://github.com/microsoft/TypeScript/issues/59108
5+
6+
declare const f: <T>(f: (x: T) => unknown) => (x: T) => unknown;
7+
>f : <T>(f: (x: T) => unknown) => (x: T) => unknown
8+
> : ^ ^^ ^^ ^^^^^
9+
>f : (x: T) => unknown
10+
> : ^ ^^ ^^^^^
11+
>x : T
12+
> : ^
13+
>x : T
14+
> : ^
15+
16+
declare const g: <T extends unknown>(x: { foo: T }) => unknown;
17+
>g : <T extends unknown>(x: { foo: T; }) => unknown
18+
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
19+
>x : { foo: T; }
20+
> : ^^^^^^^ ^^^
21+
>foo : T
22+
> : ^
23+
24+
const h = f(g);
25+
>h : <T extends unknown>(x: { foo: T; }) => unknown
26+
> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^
27+
>f(g) : <T extends unknown>(x: { foo: T; }) => unknown
28+
> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^
29+
>f : <T>(f: (x: T) => unknown) => (x: T) => unknown
30+
> : ^ ^^ ^^ ^^^^^
31+
>g : <T extends unknown>(x: { foo: T; }) => unknown
32+
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
33+
34+
type FirstParameter<T> = T extends (x: infer P) => unknown ? P : unknown;
35+
>FirstParameter : FirstParameter<T>
36+
> : ^^^^^^^^^^^^^^^^^
37+
>x : P
38+
> : ^
39+
40+
type X = FirstParameter<typeof h>["foo"];
41+
>X : unknown
42+
> : ^^^^^^^
43+
>h : <T extends unknown>(x: { foo: T; }) => unknown
44+
> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^
45+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// @strict: true
2+
// @noEmit: true
3+
4+
// https://github.com/microsoft/TypeScript/issues/59108
5+
6+
declare const f: <T>(f: (x: T) => unknown) => (x: T) => unknown;
7+
declare const g: <T extends unknown>(x: { foo: T }) => unknown;
8+
9+
const h = f(g);
10+
11+
type FirstParameter<T> = T extends (x: infer P) => unknown ? P : unknown;
12+
13+
type X = FirstParameter<typeof h>["foo"];

0 commit comments

Comments
 (0)