Fix issue with exit status by ensuring the same 'diagnostics' variable is reused.

This commit is contained in:
Daniel Rosenwasser
2015-07-31 10:40:07 -07:00
parent 7e9e920d1e
commit e74f0f0f59

View File

@@ -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);
}
}