From 9168bd4845a15b21f22ac3bd5011ad1364742208 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 25 Apr 2019 13:25:48 -0700 Subject: [PATCH] Simplify hasExportDeclarations (#27846) --- src/compiler/binder.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index ad02d84a35bdd..96db98d337a73 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1625,15 +1625,8 @@ namespace ts { } function hasExportDeclarations(node: ModuleDeclaration | SourceFile): boolean { - const body = node.kind === SyntaxKind.SourceFile ? node : node.body; - if (body && (body.kind === SyntaxKind.SourceFile || body.kind === SyntaxKind.ModuleBlock)) { - for (const stat of (body).statements) { - if (stat.kind === SyntaxKind.ExportDeclaration || stat.kind === SyntaxKind.ExportAssignment) { - return true; - } - } - } - return false; + const body = isSourceFile(node) ? node : tryCast(node.body, isModuleBlock); + return !!body && body.statements.some(s => isExportDeclaration(s) || isExportAssignment(s)); } function setExportContextFlag(node: ModuleDeclaration | SourceFile) {