From 76656f2460bd06396ff224cc9655ad1bb349993b Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 19 Sep 2014 16:18:16 -0700 Subject: [PATCH] Address code reviews --- src/compiler/tsc.ts | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 38aab5396b4..30428568d50 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -333,9 +333,8 @@ module ts { var bindStart = new Date().getTime(); var syntacticErrors = program.getDiagnostics(); - var emitErrors: Diagnostic[]; - var semanticErrors: Diagnostic[]; var errors: Diagnostic[]; + var exitStatus: EmitReturnStatus; if (syntacticErrors.length) { var checkStart = bindStart; @@ -345,9 +344,11 @@ module ts { else { var checker = program.getTypeChecker(/*fullTypeCheckMode*/ true); var checkStart = new Date().getTime(); - semanticErrors = checker.getDiagnostics(); + var semanticErrors = checker.getDiagnostics(); var emitStart = new Date().getTime(); - emitErrors = checker.emitFiles().errors; + var emitOutput = checker.emitFiles(); + var emitErrors = emitOutput.errors; + exitStatus = emitOutput.emitResultStatus; var reportStart = new Date().getTime(); errors = concatenate(syntacticErrors, concatenate(semanticErrors, emitErrors)); } @@ -371,22 +372,11 @@ module ts { reportTimeStatistic("Total time", reportStart - parseStart); } - // Check types of diagnostics and return associated exit code + // Check if there exists syntactic errors if (syntacticErrors.length > 0) { - return { program: program, exitStatus: EmitReturnStatus.AllOutputGenerationSkipped }; - } else if (semanticErrors.length > 0 && !compilerOptions.declaration) { - // No '-d' is specified; javascript file is generated with semantic errors - return { program: program, exitStatus: EmitReturnStatus.JSGeneratedWithSemanticErrors }; - } else if (semanticErrors.length > 0 && compilerOptions.declaration) { - // '-d' is specified; javascript file will be emitted with semantic errors but declaration file will be skipped - return { program: program, exitStatus: EmitReturnStatus.DeclarationGenerationSkipped }; - } else if (emitErrors.length > 0 && compilerOptions.declaration) { - return { program: program, exitStatus: EmitReturnStatus.EmitErrorsEncountered }; - } else { - // There is no error message - return { program: program, exitStatus: EmitReturnStatus.Succeeded }; - } - + exitStatus = EmitReturnStatus.AllOutputGenerationSkipped; + } + return { program: program, exitStatus: exitStatus } } function printVersion() {