diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 6872c4c876e..36f8eb226d6 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -355,18 +355,20 @@ namespace ts { return { program, exitStatus }; function compileProgram(): ExitStatus { - // First get any syntactic errors. - let diagnostics = program.getSyntacticDiagnostics(); + let diagnostics: Diagnostic[]; + + // First get and report any syntactic errors. + diagnostics = program.getSyntacticDiagnostics(); reportDiagnostics(diagnostics); // If we didn't have any syntactic errors, then also try getting the global and // semantic errors. if (diagnostics.length === 0) { - let diagnostics = program.getGlobalDiagnostics(); + diagnostics = program.getGlobalDiagnostics(); reportDiagnostics(diagnostics); if (diagnostics.length === 0) { - let diagnostics = program.getSemanticDiagnostics(); + diagnostics = program.getSemanticDiagnostics(); reportDiagnostics(diagnostics); } }