@@ -67,7 +67,7 @@ namespace ts {
67
67
let errorNameNode : DeclarationName ;
68
68
const emitJsDocComments = compilerOptions . removeComments ? noop : writeJsDocComments ;
69
69
const emit = compilerOptions . stripInternal ? stripInternal : emitNode ;
70
- let noDeclare : boolean ;
70
+ let needsDeclare = true ;
71
71
72
72
let moduleElementDeclarationEmitInfo : ModuleElementDeclarationEmitInfo [ ] = [ ] ;
73
73
let asynchronousSubModuleDeclarationEmitInfo : ModuleElementDeclarationEmitInfo [ ] ;
@@ -110,11 +110,11 @@ namespace ts {
110
110
111
111
resultHasExternalModuleIndicator = false ;
112
112
if ( ! isBundledEmit || ! isExternalModule ( sourceFile ) ) {
113
- noDeclare = false ;
113
+ needsDeclare = true ;
114
114
emitSourceFile ( sourceFile ) ;
115
115
}
116
116
else if ( isExternalModule ( sourceFile ) ) {
117
- noDeclare = true ;
117
+ needsDeclare = false ;
118
118
write ( `declare module "${ getResolvedExternalModuleName ( host , sourceFile ) } " {` ) ;
119
119
writeLine ( ) ;
120
120
increaseIndent ( ) ;
@@ -612,9 +612,9 @@ namespace ts {
612
612
}
613
613
}
614
614
615
- function emitTempVariableDeclaration ( expr : Expression , baseName : string , diagnostic : SymbolAccessibilityDiagnostic ) : string {
615
+ function emitTempVariableDeclaration ( expr : Expression , baseName : string , diagnostic : SymbolAccessibilityDiagnostic , needsDeclare : boolean ) : string {
616
616
const tempVarName = getExportTempVariableName ( baseName ) ;
617
- if ( ! noDeclare ) {
617
+ if ( needsDeclare ) {
618
618
write ( "declare " ) ;
619
619
}
620
620
write ( "const " ) ;
@@ -636,7 +636,7 @@ namespace ts {
636
636
const tempVarName = emitTempVariableDeclaration ( node . expression , "_default" , {
637
637
diagnosticMessage : Diagnostics . Default_export_of_the_module_has_or_is_using_private_name_0 ,
638
638
errorNode : node
639
- } ) ;
639
+ } , needsDeclare ) ;
640
640
write ( node . isExportEquals ? "export = " : "export default " ) ;
641
641
write ( tempVarName ) ;
642
642
}
@@ -728,7 +728,7 @@ namespace ts {
728
728
if ( modifiers & ModifierFlags . Default ) {
729
729
write ( "default " ) ;
730
730
}
731
- else if ( node . kind !== SyntaxKind . InterfaceDeclaration && ! noDeclare ) {
731
+ else if ( node . kind !== SyntaxKind . InterfaceDeclaration && needsDeclare ) {
732
732
write ( "declare " ) ;
733
733
}
734
734
}
@@ -1155,7 +1155,7 @@ namespace ts {
1155
1155
diagnosticMessage : Diagnostics . extends_clause_of_exported_class_0_has_or_is_using_private_name_1 ,
1156
1156
errorNode : baseTypeNode ,
1157
1157
typeName : node . name
1158
- } ) ;
1158
+ } , ! findAncestor ( node , n => n . kind === SyntaxKind . ModuleDeclaration ) ) ;
1159
1159
}
1160
1160
1161
1161
emitJsDocComments ( node ) ;
0 commit comments