@@ -333,9 +333,8 @@ module ts {
333
333
334
334
var bindStart = new Date ( ) . getTime ( ) ;
335
335
var syntacticErrors = program . getDiagnostics ( ) ;
336
- var emitErrors : Diagnostic [ ] ;
337
- var semanticErrors : Diagnostic [ ] ;
338
336
var errors : Diagnostic [ ] ;
337
+ var exitStatus : EmitReturnStatus ;
339
338
340
339
if ( syntacticErrors . length ) {
341
340
var checkStart = bindStart ;
@@ -345,9 +344,11 @@ module ts {
345
344
else {
346
345
var checker = program . getTypeChecker ( /*fullTypeCheckMode*/ true ) ;
347
346
var checkStart = new Date ( ) . getTime ( ) ;
348
- semanticErrors = checker . getDiagnostics ( ) ;
347
+ var semanticErrors = checker . getDiagnostics ( ) ;
349
348
var emitStart = new Date ( ) . getTime ( ) ;
350
- emitErrors = checker . emitFiles ( ) . errors ;
349
+ var emitOutput = checker . emitFiles ( ) ;
350
+ var emitErrors = emitOutput . errors ;
351
+ exitStatus = emitOutput . emitResultStatus ;
351
352
var reportStart = new Date ( ) . getTime ( ) ;
352
353
errors = concatenate ( syntacticErrors , concatenate ( semanticErrors , emitErrors ) ) ;
353
354
}
@@ -371,22 +372,11 @@ module ts {
371
372
reportTimeStatistic ( "Total time" , reportStart - parseStart ) ;
372
373
}
373
374
374
- // Check types of diagnostics and return associated exit code
375
+ // Check if there exists syntactic errors
375
376
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 }
390
380
}
391
381
392
382
function printVersion ( ) {
0 commit comments