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
This commit is contained in:
Wesley Wigham 2022-04-06 16:36:42 -07:00 committed by GitHub
parent 702bc5222b
commit 94d33ba85d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 101 additions and 0 deletions

View File

@ -1163,6 +1163,9 @@ namespace ts {
}
function transformTopLevelDeclaration(input: LateVisibilityPaintedStatement) {
if (lateMarkedStatements) {
while (orderedRemoveItem(lateMarkedStatements, input));
}
if (shouldStripInternal(input)) return;
switch (input.kind) {
case SyntaxKind.ImportEqualsDeclaration: {

View File

@ -0,0 +1,38 @@
//// [declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts]
export interface Foo {
item: Bar;
}
interface Bar {
baz(): void;
}
namespace Bar {
export function biz() {
return 0;
}
}
//// [declarationEmitNamespaceMergedWithInterfaceNestedFunction.js]
"use strict";
exports.__esModule = true;
var Bar;
(function (Bar) {
function biz() {
return 0;
}
Bar.biz = biz;
})(Bar || (Bar = {}));
//// [declarationEmitNamespaceMergedWithInterfaceNestedFunction.d.ts]
export interface Foo {
item: Bar;
}
interface Bar {
baz(): void;
}
declare namespace Bar {
function biz(): number;
}
export {};

View File

@ -0,0 +1,25 @@
=== tests/cases/compiler/declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts ===
export interface Foo {
>Foo : Symbol(Foo, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 0, 0))
item: Bar;
>item : Symbol(Foo.item, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 0, 22))
>Bar : Symbol(Bar, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 2, 1), Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 6, 1))
}
interface Bar {
>Bar : Symbol(Bar, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 2, 1), Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 6, 1))
baz(): void;
>baz : Symbol(Bar.baz, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 4, 15))
}
namespace Bar {
>Bar : Symbol(Bar, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 2, 1), Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 6, 1))
export function biz() {
>biz : Symbol(biz, Decl(declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts, 8, 15))
return 0;
}
}

View File

@ -0,0 +1,21 @@
=== tests/cases/compiler/declarationEmitNamespaceMergedWithInterfaceNestedFunction.ts ===
export interface Foo {
item: Bar;
>item : Bar
}
interface Bar {
baz(): void;
>baz : () => void
}
namespace Bar {
>Bar : typeof Bar
export function biz() {
>biz : () => number
return 0;
>0 : 0
}
}

View File

@ -0,0 +1,14 @@
// @declaration: true
export interface Foo {
item: Bar;
}
interface Bar {
baz(): void;
}
namespace Bar {
export function biz() {
return 0;
}
}