mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-09 20:51:43 -06:00
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
This commit is contained in:
parent
0d4ffed756
commit
cf167dbb6f
@ -15942,7 +15942,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 {
|
||||
|
||||
@ -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<T> extends Array<T> {}
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
//// [tests/cases/compiler/genericCallInferenceConditionalType1.ts] ////
|
||||
|
||||
=== genericCallInferenceConditionalType1.ts ===
|
||||
// https://github.com/microsoft/TypeScript/issues/59108
|
||||
|
||||
declare const f: <T>(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: <T extends unknown>(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> = 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<typeof h>["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))
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
//// [tests/cases/compiler/genericCallInferenceConditionalType1.ts] ////
|
||||
|
||||
=== genericCallInferenceConditionalType1.ts ===
|
||||
// https://github.com/microsoft/TypeScript/issues/59108
|
||||
|
||||
declare const f: <T>(f: (x: T) => unknown) => (x: T) => unknown;
|
||||
>f : <T>(f: (x: T) => unknown) => (x: T) => unknown
|
||||
> : ^ ^^ ^^ ^^^^^
|
||||
>f : (x: T) => unknown
|
||||
> : ^ ^^ ^^^^^
|
||||
>x : T
|
||||
> : ^
|
||||
>x : T
|
||||
> : ^
|
||||
|
||||
declare const g: <T extends unknown>(x: { foo: T }) => unknown;
|
||||
>g : <T extends unknown>(x: { foo: T; }) => unknown
|
||||
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
|
||||
>x : { foo: T; }
|
||||
> : ^^^^^^^ ^^^
|
||||
>foo : T
|
||||
> : ^
|
||||
|
||||
const h = f(g);
|
||||
>h : <T extends unknown>(x: { foo: T; }) => unknown
|
||||
> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^
|
||||
>f(g) : <T extends unknown>(x: { foo: T; }) => unknown
|
||||
> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^
|
||||
>f : <T>(f: (x: T) => unknown) => (x: T) => unknown
|
||||
> : ^ ^^ ^^ ^^^^^
|
||||
>g : <T extends unknown>(x: { foo: T; }) => unknown
|
||||
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
|
||||
|
||||
type FirstParameter<T> = T extends (x: infer P) => unknown ? P : unknown;
|
||||
>FirstParameter : FirstParameter<T>
|
||||
> : ^^^^^^^^^^^^^^^^^
|
||||
>x : P
|
||||
> : ^
|
||||
|
||||
type X = FirstParameter<typeof h>["foo"];
|
||||
>X : unknown
|
||||
> : ^^^^^^^
|
||||
>h : <T extends unknown>(x: { foo: T; }) => unknown
|
||||
> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^^^^^^^
|
||||
|
||||
13
tests/cases/compiler/genericCallInferenceConditionalType1.ts
Normal file
13
tests/cases/compiler/genericCallInferenceConditionalType1.ts
Normal file
@ -0,0 +1,13 @@
|
||||
// @strict: true
|
||||
// @noEmit: true
|
||||
|
||||
// https://github.com/microsoft/TypeScript/issues/59108
|
||||
|
||||
declare const f: <T>(f: (x: T) => unknown) => (x: T) => unknown;
|
||||
declare const g: <T extends unknown>(x: { foo: T }) => unknown;
|
||||
|
||||
const h = f(g);
|
||||
|
||||
type FirstParameter<T> = T extends (x: infer P) => unknown ? P : unknown;
|
||||
|
||||
type X = FirstParameter<typeof h>["foo"];
|
||||
Loading…
x
Reference in New Issue
Block a user