Skip to content

Commit 76656f2

Browse files
author
Yui T
committed
Address code reviews
1 parent eaa4daa commit 76656f2

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

src/compiler/tsc.ts

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,8 @@ module ts {
333333

334334
var bindStart = new Date().getTime();
335335
var syntacticErrors = program.getDiagnostics();
336-
var emitErrors: Diagnostic[];
337-
var semanticErrors: Diagnostic[];
338336
var errors: Diagnostic[];
337+
var exitStatus: EmitReturnStatus;
339338

340339
if (syntacticErrors.length) {
341340
var checkStart = bindStart;
@@ -345,9 +344,11 @@ module ts {
345344
else {
346345
var checker = program.getTypeChecker(/*fullTypeCheckMode*/ true);
347346
var checkStart = new Date().getTime();
348-
semanticErrors = checker.getDiagnostics();
347+
var semanticErrors = checker.getDiagnostics();
349348
var emitStart = new Date().getTime();
350-
emitErrors = checker.emitFiles().errors;
349+
var emitOutput = checker.emitFiles();
350+
var emitErrors = emitOutput.errors;
351+
exitStatus = emitOutput.emitResultStatus;
351352
var reportStart = new Date().getTime();
352353
errors = concatenate(syntacticErrors, concatenate(semanticErrors, emitErrors));
353354
}
@@ -371,22 +372,11 @@ module ts {
371372
reportTimeStatistic("Total time", reportStart - parseStart);
372373
}
373374

374-
// Check types of diagnostics and return associated exit code
375+
// Check if there exists syntactic errors
375376
if (syntacticErrors.length > 0) {
376-
return { program: program, exitStatus: EmitReturnStatus.AllOutputGenerationSkipped };
377-
} else if (semanticErrors.length > 0 && !compilerOptions.declaration) {
378-
// No '-d' is specified; javascript file is generated with semantic errors
379-
return { program: program, exitStatus: EmitReturnStatus.JSGeneratedWithSemanticErrors };
380-
} else if (semanticErrors.length > 0 && compilerOptions.declaration) {
381-
// '-d' is specified; javascript file will be emitted with semantic errors but declaration file will be skipped
382-
return { program: program, exitStatus: EmitReturnStatus.DeclarationGenerationSkipped };
383-
} else if (emitErrors.length > 0 && compilerOptions.declaration) {
384-
return { program: program, exitStatus: EmitReturnStatus.EmitErrorsEncountered };
385-
} else {
386-
// There is no error message
387-
return { program: program, exitStatus: EmitReturnStatus.Succeeded };
388-
}
389-
377+
exitStatus = EmitReturnStatus.AllOutputGenerationSkipped;
378+
}
379+
return { program: program, exitStatus: exitStatus }
390380
}
391381

392382
function printVersion() {

0 commit comments

Comments
 (0)