Skip to content

Commit 2c95ea9

Browse files
committed
[Transforms] fix Not correctly emitting local name for exported class (microsoft#8048)
* Fix 7864: by set emitFlags to not substitute the node * Address PR: fix comment
1 parent 86d7425 commit 2c95ea9

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/compiler/transformers/module/module.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,9 @@ namespace ts {
358358
return undefined;
359359
}
360360

361+
// Set emitFlags on the name of the importEqualsDeclaration
362+
// This is so the printer will not substitute the identifier
363+
setNodeEmitFlags(node.name, NodeEmitFlags.NoSubstitution);
361364
const statements: Statement[] = [];
362365
if (moduleKind !== ModuleKind.AMD) {
363366
if (hasModifier(node, ModifierFlags.Export)) {
@@ -639,6 +642,9 @@ namespace ts {
639642
function visitClassDeclaration(node: ClassDeclaration): VisitResult<Statement> {
640643
const statements: Statement[] = [];
641644
const name = node.name || getGeneratedNameForNode(node);
645+
// Set emitFlags on the name of the classDeclaration
646+
// This is so that when printer will not substitute the identifier
647+
setNodeEmitFlags(name, NodeEmitFlags.NoSubstitution);
642648
if (hasModifier(node, ModifierFlags.Export)) {
643649
statements.push(
644650
createClassDeclaration(
@@ -834,6 +840,9 @@ namespace ts {
834840
// Find the name of the module alias, if there is one
835841
const importAliasName = getLocalNameForExternalImport(importNode, currentSourceFile);
836842
if (includeNonAmdDependencies && importAliasName) {
843+
// Set emitFlags on the name of the classDeclaration
844+
// This is so that when printer will not substitute the identifier
845+
setNodeEmitFlags(importAliasName, NodeEmitFlags.NoSubstitution);
837846
aliasedModuleNames.push(externalModuleName);
838847
importAliasNames.push(createParameter(importAliasName));
839848
}

0 commit comments

Comments
 (0)