@@ -2311,27 +2311,17 @@ namespace ts {
2311
2311
if ( node . modifiers && node . modifiers . length ) {
2312
2312
file . bindDiagnostics . push ( createDiagnosticForNode ( node , Diagnostics . Modifiers_cannot_appear_here ) ) ;
2313
2313
}
2314
-
2315
- if ( node . parent . kind !== SyntaxKind . SourceFile ) {
2316
- file . bindDiagnostics . push ( createDiagnosticForNode ( node , Diagnostics . Global_module_exports_may_only_appear_at_top_level ) ) ;
2317
- return ;
2314
+ const diag = ! isSourceFile ( node . parent ) ? Diagnostics . Global_module_exports_may_only_appear_at_top_level
2315
+ : ! isExternalModule ( node . parent ) ? Diagnostics . Global_module_exports_may_only_appear_in_module_files
2316
+ : ! node . parent . isDeclarationFile ? Diagnostics . Global_module_exports_may_only_appear_in_declaration_files
2317
+ : undefined ;
2318
+ if ( diag ) {
2319
+ file . bindDiagnostics . push ( createDiagnosticForNode ( node , diag ) ) ;
2318
2320
}
2319
2321
else {
2320
- const parent = node . parent as SourceFile ;
2321
-
2322
- if ( ! isExternalModule ( parent ) ) {
2323
- file . bindDiagnostics . push ( createDiagnosticForNode ( node , Diagnostics . Global_module_exports_may_only_appear_in_module_files ) ) ;
2324
- return ;
2325
- }
2326
-
2327
- if ( ! parent . isDeclarationFile ) {
2328
- file . bindDiagnostics . push ( createDiagnosticForNode ( node , Diagnostics . Global_module_exports_may_only_appear_in_declaration_files ) ) ;
2329
- return ;
2330
- }
2322
+ file . symbol . globalExports = file . symbol . globalExports || createSymbolTable ( ) ;
2323
+ declareSymbol ( file . symbol . globalExports , file . symbol , node , SymbolFlags . Alias , SymbolFlags . AliasExcludes ) ;
2331
2324
}
2332
-
2333
- file . symbol . globalExports = file . symbol . globalExports || createSymbolTable ( ) ;
2334
- declareSymbol ( file . symbol . globalExports , file . symbol , node , SymbolFlags . Alias , SymbolFlags . AliasExcludes ) ;
2335
2325
}
2336
2326
2337
2327
function bindExportDeclaration ( node : ExportDeclaration ) {
0 commit comments