From 43bd2d8747e92aea869d55685365dd7ead53a065 Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Thu, 27 Oct 2016 16:38:59 -0700 Subject: [PATCH] Changes from CR feedback --- src/compiler/program.ts | 10 ++++++---- src/compiler/types.ts | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 6c06664d589..b7830653c86 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -727,9 +727,11 @@ namespace ts { function getSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { // For JavaScript files, we report semantic errors for using TypeScript-only // constructs from within a JavaScript file as syntactic errors. - if (isSourceFileJavaScript(sourceFile) && !sourceFile.parseJavaScriptDiagnostics) { - sourceFile.parseJavaScriptDiagnostics = getJavaScriptSemanticDiagnosticsForFile(sourceFile); - sourceFile.parseDiagnostics = sourceFile.parseDiagnostics.concat(sourceFile.parseJavaScriptDiagnostics); + if (isSourceFileJavaScript(sourceFile)) { + if (!sourceFile.additionalSyntacticDiagnostics) { + sourceFile.additionalSyntacticDiagnostics = getJavaScriptSyntacticDiagnosticsForFile(sourceFile); + } + return concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.parseDiagnostics); } return sourceFile.parseDiagnostics; } @@ -774,7 +776,7 @@ namespace ts { }); } - function getJavaScriptSemanticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { + function getJavaScriptSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { return runWithCancellationToken(() => { const diagnostics: Diagnostic[] = []; walk(sourceFile); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index bda350347c2..ff0ba2fde86 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2024,8 +2024,8 @@ namespace ts { // as well as code diagnostics). /* @internal */ parseDiagnostics: Diagnostic[]; - // Stores file level JavaScript diagnostics reported by the program - /* @internal */ parseJavaScriptDiagnostics?: Diagnostic[]; + // Stores additional file level diagnostics reported by the program + /* @internal */ additionalSyntacticDiagnostics?: Diagnostic[]; // File level diagnostics reported by the binder. /* @internal */ bindDiagnostics: Diagnostic[];