From 6ae0cd881edac60d7b8b88f6068b0a62c193c211 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 11 Oct 2018 14:50:07 -0700 Subject: [PATCH] Simplify hasExportDeclarations --- 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 292bfe51340db..2f9921543ddb5 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1569,15 +1569,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) {