Skip to content

Commit 9168bd4

Browse files
Andy HansonRyanCavanaugh
authored andcommitted
Simplify hasExportDeclarations (microsoft#27846)
1 parent 591b255 commit 9168bd4

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

src/compiler/binder.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,15 +1625,8 @@ namespace ts {
16251625
}
16261626

16271627
function hasExportDeclarations(node: ModuleDeclaration | SourceFile): boolean {
1628-
const body = node.kind === SyntaxKind.SourceFile ? node : node.body;
1629-
if (body && (body.kind === SyntaxKind.SourceFile || body.kind === SyntaxKind.ModuleBlock)) {
1630-
for (const stat of (<BlockLike>body).statements) {
1631-
if (stat.kind === SyntaxKind.ExportDeclaration || stat.kind === SyntaxKind.ExportAssignment) {
1632-
return true;
1633-
}
1634-
}
1635-
}
1636-
return false;
1628+
const body = isSourceFile(node) ? node : tryCast(node.body, isModuleBlock);
1629+
return !!body && body.statements.some(s => isExportDeclaration(s) || isExportAssignment(s));
16371630
}
16381631

16391632
function setExportContextFlag(node: ModuleDeclaration | SourceFile) {

0 commit comments

Comments
 (0)