Skip to content

Commit 115636b

Browse files
author
Andy
authored
Minor cleanup in bindNamespaceExportDeclaration (microsoft#27367)
* Minor cleanup in bindNamespaceExportDeclaration * Change formatting
1 parent bc23037 commit 115636b

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

src/compiler/binder.ts

+8-18
Original file line numberDiff line numberDiff line change
@@ -2311,27 +2311,17 @@ namespace ts {
23112311
if (node.modifiers && node.modifiers.length) {
23122312
file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Modifiers_cannot_appear_here));
23132313
}
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));
23182320
}
23192321
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);
23312324
}
2332-
2333-
file.symbol.globalExports = file.symbol.globalExports || createSymbolTable();
2334-
declareSymbol(file.symbol.globalExports, file.symbol, node, SymbolFlags.Alias, SymbolFlags.AliasExcludes);
23352325
}
23362326

23372327
function bindExportDeclaration(node: ExportDeclaration) {

0 commit comments

Comments
 (0)