diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 770e1a7c1c60a..083537b2cb351 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15958,7 +15958,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function createSignatureTypeMapper(signature: Signature, typeArguments: readonly Type[] | undefined): TypeMapper { - return createTypeMapper(signature.typeParameters!, typeArguments); + return createTypeMapper(sameMap(signature.typeParameters!, tp => tp.mapper ? instantiateType(tp, tp.mapper) : tp), typeArguments); } function getErasedSignature(signature: Signature): Signature { diff --git a/tests/baselines/reference/excessiveStackDepthFlatArray.types b/tests/baselines/reference/excessiveStackDepthFlatArray.types index 3e6c4a9dd34f1..96ae982420c09 100644 --- a/tests/baselines/reference/excessiveStackDepthFlatArray.types +++ b/tests/baselines/reference/excessiveStackDepthFlatArray.types @@ -1,7 +1,7 @@ //// [tests/cases/compiler/excessiveStackDepthFlatArray.ts] //// === Performance Stats === -Instantiation count: 1,000 +Instantiation count: 1,000 -> 2,500 === index.tsx === interface MiddlewareArray extends Array {} diff --git a/tests/baselines/reference/genericCallInferenceConditionalType1.symbols b/tests/baselines/reference/genericCallInferenceConditionalType1.symbols new file mode 100644 index 0000000000000..59e44a45eef8a --- /dev/null +++ b/tests/baselines/reference/genericCallInferenceConditionalType1.symbols @@ -0,0 +1,39 @@ +//// [tests/cases/compiler/genericCallInferenceConditionalType1.ts] //// + +=== genericCallInferenceConditionalType1.ts === +// https://github.com/microsoft/TypeScript/issues/59108 + +declare const f: (f: (x: T) => unknown) => (x: T) => unknown; +>f : Symbol(f, Decl(genericCallInferenceConditionalType1.ts, 2, 13)) +>T : Symbol(T, Decl(genericCallInferenceConditionalType1.ts, 2, 18)) +>f : Symbol(f, Decl(genericCallInferenceConditionalType1.ts, 2, 21)) +>x : Symbol(x, Decl(genericCallInferenceConditionalType1.ts, 2, 25)) +>T : Symbol(T, Decl(genericCallInferenceConditionalType1.ts, 2, 18)) +>x : Symbol(x, Decl(genericCallInferenceConditionalType1.ts, 2, 47)) +>T : Symbol(T, Decl(genericCallInferenceConditionalType1.ts, 2, 18)) + +declare const g: (x: { foo: T }) => unknown; +>g : Symbol(g, Decl(genericCallInferenceConditionalType1.ts, 3, 13)) +>T : Symbol(T, Decl(genericCallInferenceConditionalType1.ts, 3, 18)) +>x : Symbol(x, Decl(genericCallInferenceConditionalType1.ts, 3, 37)) +>foo : Symbol(foo, Decl(genericCallInferenceConditionalType1.ts, 3, 41)) +>T : Symbol(T, Decl(genericCallInferenceConditionalType1.ts, 3, 18)) + +const h = f(g); +>h : Symbol(h, Decl(genericCallInferenceConditionalType1.ts, 5, 5)) +>f : Symbol(f, Decl(genericCallInferenceConditionalType1.ts, 2, 13)) +>g : Symbol(g, Decl(genericCallInferenceConditionalType1.ts, 3, 13)) + +type FirstParameter = T extends (x: infer P) => unknown ? P : unknown; +>FirstParameter : Symbol(FirstParameter, Decl(genericCallInferenceConditionalType1.ts, 5, 15)) +>T : Symbol(T, Decl(genericCallInferenceConditionalType1.ts, 7, 20)) +>T : Symbol(T, Decl(genericCallInferenceConditionalType1.ts, 7, 20)) +>x : Symbol(x, Decl(genericCallInferenceConditionalType1.ts, 7, 36)) +>P : Symbol(P, Decl(genericCallInferenceConditionalType1.ts, 7, 44)) +>P : Symbol(P, Decl(genericCallInferenceConditionalType1.ts, 7, 44)) + +type X = FirstParameter["foo"]; +>X : Symbol(X, Decl(genericCallInferenceConditionalType1.ts, 7, 73)) +>FirstParameter : Symbol(FirstParameter, Decl(genericCallInferenceConditionalType1.ts, 5, 15)) +>h : Symbol(h, Decl(genericCallInferenceConditionalType1.ts, 5, 5)) + diff --git a/tests/baselines/reference/genericCallInferenceConditionalType1.types b/tests/baselines/reference/genericCallInferenceConditionalType1.types new file mode 100644 index 0000000000000..ef4789b2d8a12 --- /dev/null +++ b/tests/baselines/reference/genericCallInferenceConditionalType1.types @@ -0,0 +1,45 @@ +//// [tests/cases/compiler/genericCallInferenceConditionalType1.ts] //// + +=== genericCallInferenceConditionalType1.ts === +// https://github.com/microsoft/TypeScript/issues/59108 + +declare const f: (f: (x: T) => unknown) => (x: T) => unknown; +>f : (f: (x: T) => unknown) => (x: T) => unknown +> : ^ ^^ ^^ ^^^^^ +>f : (x: T) => unknown +> : ^ ^^ ^^^^^ +>x : T +> : ^ +>x : T +> : ^ + +declare const g: (x: { foo: T }) => unknown; +>g : (x: { foo: T; }) => unknown +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>x : { foo: T; } +> : ^^^^^^^ ^^^ +>foo : T +> : ^ + +const h = f(g); +>h : (x: { foo: T; }) => unknown +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^ +>f(g) : (x: { foo: T; }) => unknown +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^ +>f : (f: (x: T) => unknown) => (x: T) => unknown +> : ^ ^^ ^^ ^^^^^ +>g : (x: { foo: T; }) => unknown +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ + +type FirstParameter = T extends (x: infer P) => unknown ? P : unknown; +>FirstParameter : FirstParameter +> : ^^^^^^^^^^^^^^^^^ +>x : P +> : ^ + +type X = FirstParameter["foo"]; +>X : unknown +> : ^^^^^^^ +>h : (x: { foo: T; }) => unknown +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^ + diff --git a/tests/cases/compiler/genericCallInferenceConditionalType1.ts b/tests/cases/compiler/genericCallInferenceConditionalType1.ts new file mode 100644 index 0000000000000..351b9bffa73e4 --- /dev/null +++ b/tests/cases/compiler/genericCallInferenceConditionalType1.ts @@ -0,0 +1,13 @@ +// @strict: true +// @noEmit: true + +// https://github.com/microsoft/TypeScript/issues/59108 + +declare const f: (f: (x: T) => unknown) => (x: T) => unknown; +declare const g: (x: { foo: T }) => unknown; + +const h = f(g); + +type FirstParameter = T extends (x: infer P) => unknown ? P : unknown; + +type X = FirstParameter["foo"];