Skip to content

Commit 481f9c8

Browse files
committed
Merge branch 'main' of https://github.com/microsoft/TypeScript into 57026
2 parents a70c773 + c85e626 commit 481f9c8

6 files changed

Lines changed: 134 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
name: coverage
9696
path: coverage
9797

98-
- uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 # v5.3.1
98+
- uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5.4.0
9999
with:
100100
use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }}
101101
disable_search: true
@@ -137,7 +137,7 @@ jobs:
137137
node-version: 'lts/*'
138138
- run: npm ci
139139

140-
- uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
140+
- uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
141141
with:
142142
path: ~/.cache/dprint
143143
key: ${{ runner.os }}-dprint-${{ hashFiles('package-lock.json', '.dprint.jsonc') }}

src/compiler/expressionToTypeNode.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,15 +1122,16 @@ export function createSyntacticTypeNodeBuilder(
11221122
);
11231123
}
11241124
function reuseTypeParameters(typeParameters: NodeArray<TypeParameterDeclaration> | undefined, context: SyntacticTypeNodeBuilderContext) {
1125-
return typeParameters?.map(tp =>
1126-
factory.updateTypeParameterDeclaration(
1125+
return typeParameters?.map(tp => {
1126+
const { node: tpName } = resolver.trackExistingEntityName(context, tp.name);
1127+
return factory.updateTypeParameterDeclaration(
11271128
tp,
11281129
tp.modifiers?.map(m => reuseNode(context, m)),
1129-
reuseNode(context, tp.name),
1130+
tpName,
11301131
serializeExistingTypeNodeWithFallback(tp.constraint, context),
11311132
serializeExistingTypeNodeWithFallback(tp.default, context),
1132-
)
1133-
);
1133+
);
1134+
});
11341135
}
11351136

11361137
function typeFromObjectLiteralMethod(method: MethodDeclaration, name: PropertyName, context: SyntacticTypeNodeBuilderContext, isConstContext: boolean) {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//// [tests/cases/compiler/declarationEmitShadowing.ts] ////
2+
3+
//// [declarationEmitShadowing.ts]
4+
export class A<T = any> {
5+
public readonly ShadowedButDoesNotRequireRenaming = <T>(): T => {
6+
return null as any
7+
}
8+
}
9+
10+
export function needsRenameForShadowing<T>() {
11+
type A = T
12+
return function O<T>(t: A, t2: T) {
13+
}
14+
}
15+
16+
17+
//// [declarationEmitShadowing.js]
18+
"use strict";
19+
Object.defineProperty(exports, "__esModule", { value: true });
20+
exports.A = void 0;
21+
exports.needsRenameForShadowing = needsRenameForShadowing;
22+
var A = /** @class */ (function () {
23+
function A() {
24+
this.ShadowedButDoesNotRequireRenaming = function () {
25+
return null;
26+
};
27+
}
28+
return A;
29+
}());
30+
exports.A = A;
31+
function needsRenameForShadowing() {
32+
return function O(t, t2) {
33+
};
34+
}
35+
36+
37+
//// [declarationEmitShadowing.d.ts]
38+
export declare class A<T = any> {
39+
readonly ShadowedButDoesNotRequireRenaming: <T_1>() => T_1;
40+
}
41+
export declare function needsRenameForShadowing<T>(): <T_1>(t: T, t2: T_1) => void;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//// [tests/cases/compiler/declarationEmitShadowing.ts] ////
2+
3+
=== declarationEmitShadowing.ts ===
4+
export class A<T = any> {
5+
>A : Symbol(A, Decl(declarationEmitShadowing.ts, 0, 0))
6+
>T : Symbol(T, Decl(declarationEmitShadowing.ts, 0, 15))
7+
8+
public readonly ShadowedButDoesNotRequireRenaming = <T>(): T => {
9+
>ShadowedButDoesNotRequireRenaming : Symbol(A.ShadowedButDoesNotRequireRenaming, Decl(declarationEmitShadowing.ts, 0, 25))
10+
>T : Symbol(T, Decl(declarationEmitShadowing.ts, 1, 55))
11+
>T : Symbol(T, Decl(declarationEmitShadowing.ts, 1, 55))
12+
13+
return null as any
14+
}
15+
}
16+
17+
export function needsRenameForShadowing<T>() {
18+
>needsRenameForShadowing : Symbol(needsRenameForShadowing, Decl(declarationEmitShadowing.ts, 4, 1))
19+
>T : Symbol(T, Decl(declarationEmitShadowing.ts, 6, 40))
20+
21+
type A = T
22+
>A : Symbol(A, Decl(declarationEmitShadowing.ts, 6, 46))
23+
>T : Symbol(T, Decl(declarationEmitShadowing.ts, 6, 40))
24+
25+
return function O<T>(t: A, t2: T) {
26+
>O : Symbol(O, Decl(declarationEmitShadowing.ts, 8, 8))
27+
>T : Symbol(T, Decl(declarationEmitShadowing.ts, 8, 20))
28+
>t : Symbol(t, Decl(declarationEmitShadowing.ts, 8, 23))
29+
>A : Symbol(A, Decl(declarationEmitShadowing.ts, 6, 46))
30+
>t2 : Symbol(t2, Decl(declarationEmitShadowing.ts, 8, 28))
31+
>T : Symbol(T, Decl(declarationEmitShadowing.ts, 8, 20))
32+
}
33+
}
34+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//// [tests/cases/compiler/declarationEmitShadowing.ts] ////
2+
3+
=== declarationEmitShadowing.ts ===
4+
export class A<T = any> {
5+
>A : A<T>
6+
> : ^^^^
7+
8+
public readonly ShadowedButDoesNotRequireRenaming = <T>(): T => {
9+
>ShadowedButDoesNotRequireRenaming : <T_1>() => T_1
10+
> : ^^^^^^^^^^^
11+
><T>(): T => { return null as any } : <T_1>() => T_1
12+
> : ^^^^^^^^^^^
13+
14+
return null as any
15+
>null as any : any
16+
}
17+
}
18+
19+
export function needsRenameForShadowing<T>() {
20+
>needsRenameForShadowing : <T>() => <T_1>(t: T, t2: T_1) => void
21+
> : ^ ^^^^^^^^ ^^ ^^^ ^^^^^^^^^
22+
23+
type A = T
24+
>A : T
25+
> : ^
26+
27+
return function O<T>(t: A, t2: T) {
28+
>function O<T>(t: A, t2: T) { } : <T_1>(t: T, t2: T_1) => void
29+
> : ^^^^^^ ^^^^^ ^^ ^^^^^^^^^
30+
>O : <T>(t: T_1, t2: T) => void
31+
> : ^ ^^ ^^^^^^^ ^^ ^^^^^^^^^
32+
>t : T_1
33+
> : ^^^
34+
>t2 : T
35+
> : ^
36+
}
37+
}
38+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// @declaration: true
2+
3+
export class A<T = any> {
4+
public readonly ShadowedButDoesNotRequireRenaming = <T>(): T => {
5+
return null as any
6+
}
7+
}
8+
9+
export function needsRenameForShadowing<T>() {
10+
type A = T
11+
return function O<T>(t: A, t2: T) {
12+
}
13+
}

0 commit comments

Comments
 (0)