Skip to content

Commit 28d95bf

Browse files
authored
Fixed an issue with type params being renamed incorrectly (#1833)
1 parent 0fbc06e commit 28d95bf

27 files changed

+23848
-27166
lines changed

internal/checker/nodebuilderscopes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ func cloneNodeBuilderContext(context *NodeBuilderContext) func() {
2424
// export const y: <T_1>(x: T_1) => T_1
2525
oldMustCreateTypeParameterSymbolList := context.hasCreatedTypeParameterSymbolList
2626
oldMustCreateTypeParametersNamesLookups := context.hasCreatedTypeParametersNamesLookups
27-
context.hasCreatedTypeParameterSymbolList = false
28-
context.hasCreatedTypeParametersNamesLookups = false
2927
oldTypeParameterNames := context.typeParameterNames
3028
oldTypeParameterNamesByText := context.typeParameterNamesByText
3129
oldTypeParameterNamesByTextNextNameCount := context.typeParameterNamesByTextNextNameCount
3230
oldTypeParameterSymbolList := context.typeParameterSymbolList
31+
context.hasCreatedTypeParameterSymbolList = oldTypeParameterSymbolList != nil
32+
context.hasCreatedTypeParametersNamesLookups = oldTypeParameterNames != nil
3333
context.typeParameterNames = maps.Clone(context.typeParameterNames)
3434
context.typeParameterNamesByText = maps.Clone(context.typeParameterNamesByText)
3535
context.typeParameterNamesByTextNextNameCount = maps.Clone(context.typeParameterNamesByTextNextNameCount)

testdata/baselines/reference/submodule/compiler/computedTypesKeyofNoIndexSignatureType.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
=== computedTypesKeyofNoIndexSignatureType.ts ===
44
type Compute<A> = { [K in keyof A]: Compute<A[K]>; } & {};
5-
>Compute : { [K in keyof A]: A[K_1] extends infer T ? { [K in keyof T]: A[K_1][K_2] extends infer T ? { [K in keyof T]: A[K_1][K_2][K_3] extends infer T ? { [K in keyof T]: A[K_1][K_2][K_3][K_4] extends infer T ? { [K in keyof T]: A[K_1][K_2][K_3][K_4][K_5] extends infer T ? { [K in keyof T]: A[K_1][K_2][K_3][K_4][K_5][K_6] extends infer T ? { [K in keyof T]: A[K_1][K_2][K_3][K_4][K_5][K_6][K_7] extends infer T ? { [K in keyof T]: A[K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8] extends infer T ? { [K in keyof T]: A[K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] extends infer T ? { [K in keyof T]: A[K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10] extends infer T ? { [K in keyof T]: any; } : never; } : never; } : never; } : never; } : never; } : never; } : never; } : never; } : never; } : never; }
5+
>Compute : { [K in keyof A]: A[K] extends infer T ? { [K_1 in keyof T]: A[K][K_1] extends infer T_1 ? { [K_2 in keyof T_1]: A[K][K_1][K_2] extends infer T_2 ? { [K_3 in keyof T_2]: A[K][K_1][K_2][K_3] extends infer T_3 ? { [K_4 in keyof T_3]: A[K][K_1][K_2][K_3][K_4] extends infer T_4 ? { [K_5 in keyof T_4]: A[K][K_1][K_2][K_3][K_4][K_5] extends infer T_5 ? { [K_6 in keyof T_5]: A[K][K_1][K_2][K_3][K_4][K_5][K_6] extends infer T_6 ? { [K_7 in keyof T_6]: A[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7] extends infer T_7 ? { [K_8 in keyof T_7]: A[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8] extends infer T_8 ? { [K_9 in keyof T_8]: A[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] extends infer T_9 ? { [K_10 in keyof T_9]: any; } : never; } : never; } : never; } : never; } : never; } : never; } : never; } : never; } : never; } : never; }
66

77
type EqualsTest<T> = <A>() => A extends T ? 1 : 0;
88
>EqualsTest : EqualsTest<T>

testdata/baselines/reference/submodule/compiler/computedTypesKeyofNoIndexSignatureType.types.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
=== computedTypesKeyofNoIndexSignatureType.ts ===
66
type Compute<A> = { [K in keyof A]: Compute<A[K]>; } & {};
77
->Compute : { [K in keyof A]: A[K] extends infer T ? { [K_1 in keyof T]: T[K_1] extends infer T_1 ? { [K_2 in keyof T_1]: T_1[K_2] extends infer T_2 ? { [K_3 in keyof T_2]: T_2[K_3] extends infer T_3 ? { [K_4 in keyof T_3]: T_3[K_4] extends infer T_4 ? { [K_5 in keyof T_4]: T_4[K_5] extends infer T_5 ? { [K_6 in keyof T_5]: T_5[K_6] extends infer T_6 ? { [K_7 in keyof T_6]: T_6[K_7] extends infer T_7 ? { [K_8 in keyof T_7]: T_7[K_8] extends infer T_8 ? { [K_9 in keyof T_8]: T_8[K_9] extends infer T_9 ? { [K_10 in keyof T_9]: any; } : never; } : never; } : never; } : never; } : never; } : never; } : never; } : never; } : never; } : never; }
8-
+>Compute : { [K in keyof A]: A[K_1] extends infer T ? { [K in keyof T]: A[K_1][K_2] extends infer T ? { [K in keyof T]: A[K_1][K_2][K_3] extends infer T ? { [K in keyof T]: A[K_1][K_2][K_3][K_4] extends infer T ? { [K in keyof T]: A[K_1][K_2][K_3][K_4][K_5] extends infer T ? { [K in keyof T]: A[K_1][K_2][K_3][K_4][K_5][K_6] extends infer T ? { [K in keyof T]: A[K_1][K_2][K_3][K_4][K_5][K_6][K_7] extends infer T ? { [K in keyof T]: A[K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8] extends infer T ? { [K in keyof T]: A[K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] extends infer T ? { [K in keyof T]: A[K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10] extends infer T ? { [K in keyof T]: any; } : never; } : never; } : never; } : never; } : never; } : never; } : never; } : never; } : never; } : never; }
8+
+>Compute : { [K in keyof A]: A[K] extends infer T ? { [K_1 in keyof T]: A[K][K_1] extends infer T_1 ? { [K_2 in keyof T_1]: A[K][K_1][K_2] extends infer T_2 ? { [K_3 in keyof T_2]: A[K][K_1][K_2][K_3] extends infer T_3 ? { [K_4 in keyof T_3]: A[K][K_1][K_2][K_3][K_4] extends infer T_4 ? { [K_5 in keyof T_4]: A[K][K_1][K_2][K_3][K_4][K_5] extends infer T_5 ? { [K_6 in keyof T_5]: A[K][K_1][K_2][K_3][K_4][K_5][K_6] extends infer T_6 ? { [K_7 in keyof T_6]: A[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7] extends infer T_7 ? { [K_8 in keyof T_7]: A[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8] extends infer T_8 ? { [K_9 in keyof T_8]: A[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] extends infer T_9 ? { [K_10 in keyof T_9]: any; } : never; } : never; } : never; } : never; } : never; } : never; } : never; } : never; } : never; } : never; }
99

1010
type EqualsTest<T> = <A>() => A extends T ? 1 : 0;
1111
>EqualsTest : EqualsTest<T>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Api.ts(6,5): error TS7056: The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.
2+
Api.ts(7,5): error TS7056: The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.
3+
Api.ts(8,5): error TS7056: The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.
4+
5+
6+
==== http-client.ts (0 errors) ====
7+
type TPromise<ResolveType, RejectType = any> = Omit<Promise<ResolveType>, "then" | "catch"> & {
8+
then<TResult1 = ResolveType, TResult2 = never>(
9+
onfulfilled?: ((value: ResolveType) => TResult1 | PromiseLike<TResult1>) | undefined | null,
10+
onrejected?: ((reason: RejectType) => TResult2 | PromiseLike<TResult2>) | undefined | null,
11+
): TPromise<TResult1 | TResult2, RejectType>;
12+
catch<TResult = never>(
13+
onrejected?: ((reason: RejectType) => TResult | PromiseLike<TResult>) | undefined | null,
14+
): TPromise<ResolveType | TResult, RejectType>;
15+
};
16+
17+
export interface HttpResponse<D extends unknown, E extends unknown = unknown> extends Response {
18+
data: D;
19+
error: E;
20+
}
21+
22+
export class HttpClient<SecurityDataType = unknown> {
23+
public request = <T = any, E = any>(): TPromise<HttpResponse<T, E>> => {
24+
return '' as any;
25+
};
26+
}
27+
==== Api.ts (3 errors) ====
28+
import { HttpClient } from "./http-client";
29+
30+
export class Api<SecurityDataType = unknown> {
31+
constructor(private http: HttpClient<SecurityDataType>) { }
32+
33+
abc1 = () => this.http.request();
34+
~~~~
35+
!!! error TS7056: The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.
36+
abc2 = () => this.http.request();
37+
~~~~
38+
!!! error TS7056: The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.
39+
abc3 = () => this.http.request();
40+
~~~~
41+
!!! error TS7056: The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.
42+
}

testdata/baselines/reference/submodule/compiler/declarationEmitPrivatePromiseLikeInterface.errors.txt.diff

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)