Skip to content

Commit 94d33ba

Browse files
authored
Ensure late painted statements are only transformed once, so inner substitutions are consistently read (#48558)
* Ensure late painted statements are only transformed once, so inner substitutions are consistently read * PR suggestion * Fix lint
1 parent 702bc52 commit 94d33ba

5 files changed

+101
-0
lines changed

src/compiler/transformers/declarations.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,9 @@ namespace ts {
11631163
}
11641164

11651165
function transformTopLevelDeclaration(input: LateVisibilityPaintedStatement) {
1166+
if (lateMarkedStatements) {
1167+
while (orderedRemoveItem(lateMarkedStatements, input));
1168+
}
11661169
if (shouldStripInternal(input)) return;
11671170
switch (input.kind) {
11681171
case SyntaxKind.ImportEqualsDeclaration: {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//// [declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts]
2+
export interface Foo {
3+
item: Bar;
4+
}
5+
6+
interface Bar {
7+
baz(): void;
8+
}
9+
10+
namespace Bar {
11+
export function biz() {
12+
return 0;
13+
}
14+
}
15+
16+
//// [declarationEmitNamespaceMergedWithInterfaceNestedFunction.js]
17+
"use strict";
18+
exports.__esModule = true;
19+
var Bar;
20+
(function (Bar) {
21+
function biz() {
22+
return 0;
23+
}
24+
Bar.biz = biz;
25+
})(Bar || (Bar = {}));
26+
27+
28+
//// [declarationEmitNamespaceMergedWithInterfaceNestedFunction.d.ts]
29+
export interface Foo {
30+
item: Bar;
31+
}
32+
interface Bar {
33+
baz(): void;
34+
}
35+
declare namespace Bar {
36+
function biz(): number;
37+
}
38+
export {};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
=== tests/cases/compiler/declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts ===
2+
export interface Foo {
3+
>Foo : Symbol(Foo, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 0, 0))
4+
5+
item: Bar;
6+
>item : Symbol(Foo.item, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 0, 22))
7+
>Bar : Symbol(Bar, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 2, 1), Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 6, 1))
8+
}
9+
10+
interface Bar {
11+
>Bar : Symbol(Bar, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 2, 1), Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 6, 1))
12+
13+
baz(): void;
14+
>baz : Symbol(Bar.baz, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 4, 15))
15+
}
16+
17+
namespace Bar {
18+
>Bar : Symbol(Bar, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 2, 1), Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 6, 1))
19+
20+
export function biz() {
21+
>biz : Symbol(biz, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 8, 15))
22+
23+
return 0;
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
=== tests/cases/compiler/declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts ===
2+
export interface Foo {
3+
item: Bar;
4+
>item : Bar
5+
}
6+
7+
interface Bar {
8+
baz(): void;
9+
>baz : () => void
10+
}
11+
12+
namespace Bar {
13+
>Bar : typeof Bar
14+
15+
export function biz() {
16+
>biz : () => number
17+
18+
return 0;
19+
>0 : 0
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// @declaration: true
2+
export interface Foo {
3+
item: Bar;
4+
}
5+
6+
interface Bar {
7+
baz(): void;
8+
}
9+
10+
namespace Bar {
11+
export function biz() {
12+
return 0;
13+
}
14+
}

0 commit comments

Comments
 (0)