Skip to content

Commit 03bca49

Browse files
committed
Correctly emit expression in extends in namespace
Shouldn't have a declare for the emitted temp
1 parent 5cd9f4e commit 03bca49

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/compiler/declarationEmitter.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ namespace ts {
6767
let errorNameNode: DeclarationName;
6868
const emitJsDocComments = compilerOptions.removeComments ? noop : writeJsDocComments;
6969
const emit = compilerOptions.stripInternal ? stripInternal : emitNode;
70-
let noDeclare: boolean;
70+
let needsDeclare: boolean = true;
7171

7272
let moduleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[] = [];
7373
let asynchronousSubModuleDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[];
@@ -110,11 +110,11 @@ namespace ts {
110110

111111
resultHasExternalModuleIndicator = false;
112112
if (!isBundledEmit || !isExternalModule(sourceFile)) {
113-
noDeclare = false;
113+
needsDeclare = true;
114114
emitSourceFile(sourceFile);
115115
}
116116
else if (isExternalModule(sourceFile)) {
117-
noDeclare = true;
117+
needsDeclare = false;
118118
write(`declare module "${getResolvedExternalModuleName(host, sourceFile)}" {`);
119119
writeLine();
120120
increaseIndent();
@@ -612,9 +612,9 @@ namespace ts {
612612
}
613613
}
614614

615-
function emitTempVariableDeclaration(expr: Expression, baseName: string, diagnostic: SymbolAccessibilityDiagnostic): string {
615+
function emitTempVariableDeclaration(expr: Expression, baseName: string, diagnostic: SymbolAccessibilityDiagnostic, needsDeclare: boolean): string {
616616
const tempVarName = getExportTempVariableName(baseName);
617-
if (!noDeclare) {
617+
if (needsDeclare) {
618618
write("declare ");
619619
}
620620
write("const ");
@@ -636,7 +636,7 @@ namespace ts {
636636
const tempVarName = emitTempVariableDeclaration(node.expression, "_default", {
637637
diagnosticMessage: Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0,
638638
errorNode: node
639-
});
639+
}, needsDeclare);
640640
write(node.isExportEquals ? "export = " : "export default ");
641641
write(tempVarName);
642642
}
@@ -728,7 +728,7 @@ namespace ts {
728728
if (modifiers & ModifierFlags.Default) {
729729
write("default ");
730730
}
731-
else if (node.kind !== SyntaxKind.InterfaceDeclaration && !noDeclare) {
731+
else if (node.kind !== SyntaxKind.InterfaceDeclaration && needsDeclare) {
732732
write("declare ");
733733
}
734734
}
@@ -1155,7 +1155,7 @@ namespace ts {
11551155
diagnosticMessage: Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1,
11561156
errorNode: baseTypeNode,
11571157
typeName: node.name
1158-
});
1158+
}, !findAncestor(node, n => n.kind === SyntaxKind.ModuleDeclaration));
11591159
}
11601160

11611161
emitJsDocComments(node);

0 commit comments

Comments
 (0)