@@ -1560,6 +1560,7 @@ namespace ts {
15601560 }
15611561
15621562 function getDiagnosticsProducingTypeChecker ( ) {
1563+ Debug . assert ( ! options . listFilesOnly || ! ! options . extendedDiagnostics ) ;
15631564 return diagnosticsProducingTypeChecker || ( diagnosticsProducingTypeChecker = createTypeChecker ( program , /*produceDiagnostics:*/ true ) ) ;
15641565 }
15651566
@@ -1582,11 +1583,11 @@ namespace ts {
15821583 function emitWorker ( program : Program , sourceFile : SourceFile | undefined , writeFileCallback : WriteFileCallback | undefined , cancellationToken : CancellationToken | undefined , emitOnlyDtsFiles ?: boolean , customTransformers ?: CustomTransformers , forceDtsEmit ?: boolean ) : EmitResult {
15831584 let declarationDiagnostics : readonly Diagnostic [ ] = [ ] ;
15841585
1585- if ( ! forceDtsEmit ) {
1586- if ( options . noEmit ) {
1587- return { diagnostics : declarationDiagnostics , sourceMaps : undefined , emittedFiles : undefined , emitSkipped : true } ;
1588- }
1586+ if ( options . listFilesOnly || ( ! forceDtsEmit && shouldSuppressEmit ( options ) ) ) {
1587+ return { diagnostics : declarationDiagnostics , sourceMaps : undefined , emittedFiles : undefined , emitSkipped : true } ;
1588+ }
15891589
1590+ if ( ! forceDtsEmit ) {
15901591 // If the noEmitOnError flag is set, then check if we have any errors so far. If so,
15911592 // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we
15921593 // get any preEmit diagnostics, not just the ones
@@ -2036,7 +2037,9 @@ namespace ts {
20362037 }
20372038
20382039 function getGlobalDiagnostics ( ) : SortedReadonlyArray < Diagnostic > {
2039- return rootNames . length ? sortAndDeduplicateDiagnostics ( getDiagnosticsProducingTypeChecker ( ) . getGlobalDiagnostics ( ) . slice ( ) ) : emptyArray as any as SortedReadonlyArray < Diagnostic > ;
2040+ return ! options . listFilesOnly && rootNames . length
2041+ ? sortAndDeduplicateDiagnostics ( getDiagnosticsProducingTypeChecker ( ) . getGlobalDiagnostics ( ) . slice ( ) )
2042+ : emptyArray as any as SortedReadonlyArray < Diagnostic > ;
20402043 }
20412044
20422045 function getConfigFileParsingDiagnostics ( ) : readonly Diagnostic [ ] {
@@ -3089,7 +3092,7 @@ namespace ts {
30893092 createDiagnosticForOptionName ( Diagnostics . Option_0_cannot_be_specified_without_specifying_option_1_or_option_2 , "emitDeclarationOnly" , "declaration" , "composite" ) ;
30903093 }
30913094
3092- if ( options . noEmit ) {
3095+ if ( shouldSuppressEmit ( options ) ) {
30933096 createDiagnosticForOptionName ( Diagnostics . Option_0_cannot_be_specified_with_option_1 , "emitDeclarationOnly" , "noEmit" ) ;
30943097 }
30953098 }
@@ -3112,7 +3115,7 @@ namespace ts {
31123115 }
31133116
31143117 // If the emit is enabled make sure that every output file is unique and not overwriting any of the input files
3115- if ( ! options . noEmit && ! options . suppressOutputPathCheck ) {
3118+ if ( ! shouldSuppressEmit ( options ) && ! options . suppressOutputPathCheck ) {
31163119 const emitHost = getEmitHost ( ) ;
31173120 const emitFilesSeen = createMap < true > ( ) ;
31183121 forEachEmittedFile ( emitHost , ( emitFileNames ) => {
@@ -3181,7 +3184,7 @@ namespace ts {
31813184 }
31823185
31833186 function verifyProjectReferences ( ) {
3184- const buildInfoPath = ! options . noEmit && ! options . suppressOutputPathCheck ? getTsBuildInfoEmitOutputFilePath ( options ) : undefined ;
3187+ const buildInfoPath = ! shouldSuppressEmit ( options ) && ! options . suppressOutputPathCheck ? getTsBuildInfoEmitOutputFilePath ( options ) : undefined ;
31853188 forEachProjectReference ( projectReferences , resolvedProjectReferences , ( resolvedRef , index , parent ) => {
31863189 const ref = ( parent ? parent . commandLine . projectReferences : projectReferences ) ! [ index ] ;
31873190 const parentFile = parent && parent . sourceFile as JsonSourceFile ;
@@ -3322,7 +3325,7 @@ namespace ts {
33223325 }
33233326
33243327 function isEmittedFile ( file : string ) : boolean {
3325- if ( options . noEmit ) {
3328+ if ( shouldSuppressEmit ( options ) ) {
33263329 return false ;
33273330 }
33283331
0 commit comments