@@ -1570,37 +1570,9 @@ namespace ts {
1570
1570
}
1571
1571
1572
1572
function emitWorker ( program : Program , sourceFile : SourceFile | undefined , writeFileCallback : WriteFileCallback | undefined , cancellationToken : CancellationToken | undefined , emitOnlyDtsFiles ?: boolean , customTransformers ?: CustomTransformers , forceDtsEmit ?: boolean ) : EmitResult {
1573
- let declarationDiagnostics : readonly Diagnostic [ ] = [ ] ;
1574
-
1575
1573
if ( ! forceDtsEmit ) {
1576
- if ( options . noEmit ) {
1577
- return { diagnostics : declarationDiagnostics , sourceMaps : undefined , emittedFiles : undefined , emitSkipped : true } ;
1578
- }
1579
-
1580
- // If the noEmitOnError flag is set, then check if we have any errors so far. If so,
1581
- // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we
1582
- // get any preEmit diagnostics, not just the ones
1583
- if ( options . noEmitOnError ) {
1584
- const diagnostics = [
1585
- ...program . getOptionsDiagnostics ( cancellationToken ) ,
1586
- ...program . getSyntacticDiagnostics ( sourceFile , cancellationToken ) ,
1587
- ...program . getGlobalDiagnostics ( cancellationToken ) ,
1588
- ...program . getSemanticDiagnostics ( sourceFile , cancellationToken )
1589
- ] ;
1590
-
1591
- if ( diagnostics . length === 0 && getEmitDeclarations ( program . getCompilerOptions ( ) ) ) {
1592
- declarationDiagnostics = program . getDeclarationDiagnostics ( /*sourceFile*/ undefined , cancellationToken ) ;
1593
- }
1594
-
1595
- if ( diagnostics . length > 0 || declarationDiagnostics . length > 0 ) {
1596
- return {
1597
- diagnostics : concatenate ( diagnostics , declarationDiagnostics ) ,
1598
- sourceMaps : undefined ,
1599
- emittedFiles : undefined ,
1600
- emitSkipped : true
1601
- } ;
1602
- }
1603
- }
1574
+ const result = handleNoEmitOptions ( program , sourceFile , cancellationToken ) ;
1575
+ if ( result ) return result ;
1604
1576
}
1605
1577
1606
1578
// Create the emit resolver outside of the "emitTime" tracking code below. That way
@@ -3442,6 +3414,33 @@ namespace ts {
3442
3414
}
3443
3415
}
3444
3416
3417
+ /*@internal */
3418
+ export function handleNoEmitOptions ( program : ProgramToEmitFilesAndReportErrors , sourceFile : SourceFile | undefined , cancellationToken : CancellationToken | undefined ) : EmitResult | undefined {
3419
+ const options = program . getCompilerOptions ( ) ;
3420
+ if ( options . noEmit ) {
3421
+ return { diagnostics : emptyArray , sourceMaps : undefined , emittedFiles : undefined , emitSkipped : true } ;
3422
+ }
3423
+
3424
+ // If the noEmitOnError flag is set, then check if we have any errors so far. If so,
3425
+ // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we
3426
+ // get any preEmit diagnostics, not just the ones
3427
+ if ( ! options . noEmitOnError ) return undefined ;
3428
+ let diagnostics : readonly Diagnostic [ ] = [
3429
+ ...program . getOptionsDiagnostics ( cancellationToken ) ,
3430
+ ...program . getSyntacticDiagnostics ( sourceFile , cancellationToken ) ,
3431
+ ...program . getGlobalDiagnostics ( cancellationToken ) ,
3432
+ ...program . getSemanticDiagnostics ( sourceFile , cancellationToken )
3433
+ ] ;
3434
+
3435
+ if ( diagnostics . length === 0 && getEmitDeclarations ( program . getCompilerOptions ( ) ) ) {
3436
+ diagnostics = program . getDeclarationDiagnostics ( /*sourceFile*/ undefined , cancellationToken ) ;
3437
+ }
3438
+
3439
+ return diagnostics . length > 0 ?
3440
+ { diagnostics, sourceMaps : undefined , emittedFiles : undefined , emitSkipped : true } :
3441
+ undefined ;
3442
+ }
3443
+
3445
3444
/*@internal */
3446
3445
interface CompilerHostLike {
3447
3446
useCaseSensitiveFileNames ( ) : boolean ;
0 commit comments