@@ -394,7 +394,7 @@ namespace ts {
394394 const projectStatus = createFileMap < UpToDateStatus > ( toPath ) ;
395395 const missingRoots = createMap < true > ( ) ;
396396 let globalDependencyGraph : DependencyGraph | undefined ;
397- const writeFileName = ( s : string ) => host . trace && host . trace ( s ) ;
397+ const writeFileName = host . trace ? ( s : string ) => host . trace ! ( s ) : undefined ;
398398 let readFileWithCache = ( f : string ) => host . readFile ( f ) ;
399399 let projectCompilerOptions = baseCompilerOptions ;
400400 const compilerHost = createCompilerHostFromProgramHost ( host , ( ) => projectCompilerOptions ) ;
@@ -1129,7 +1129,7 @@ namespace ts {
11291129 let declDiagnostics : Diagnostic [ ] | undefined ;
11301130 const reportDeclarationDiagnostics = ( d : Diagnostic ) => ( declDiagnostics || ( declDiagnostics = [ ] ) ) . push ( d ) ;
11311131 const outputFiles : OutputFile [ ] = [ ] ;
1132- emitFilesAndReportErrors ( program , reportDeclarationDiagnostics , writeFileName , /*reportSummary*/ undefined , ( name , text , writeByteOrderMark ) => outputFiles . push ( { name, text, writeByteOrderMark } ) ) ;
1132+ emitFilesAndReportErrors ( program , reportDeclarationDiagnostics , /* writeFileName*/ undefined , /*reportSummary*/ undefined , ( name , text , writeByteOrderMark ) => outputFiles . push ( { name, text, writeByteOrderMark } ) ) ;
11331133 // Don't emit .d.ts if there are decl file errors
11341134 if ( declDiagnostics ) {
11351135 program . restoreState ( ) ;
@@ -1138,7 +1138,7 @@ namespace ts {
11381138
11391139 // Actual Emit
11401140 const emitterDiagnostics = createDiagnosticCollection ( ) ;
1141- const emittedOutputs = createFileMap < true > ( toPath as ToPath ) ;
1141+ const emittedOutputs = createFileMap < string > ( toPath as ToPath ) ;
11421142 outputFiles . forEach ( ( { name, text, writeByteOrderMark } ) => {
11431143 let priorChangeTime : Date | undefined ;
11441144 if ( ! anyDtsChanged && isDeclarationFile ( name ) ) {
@@ -1152,7 +1152,7 @@ namespace ts {
11521152 }
11531153 }
11541154
1155- emittedOutputs . setValue ( name , true ) ;
1155+ emittedOutputs . setValue ( name , name ) ;
11561156 writeFile ( compilerHost , emitterDiagnostics , name , text , writeByteOrderMark ) ;
11571157 if ( priorChangeTime !== undefined ) {
11581158 newestDeclarationFileContentChangedTime = newer ( priorChangeTime , newestDeclarationFileContentChangedTime ) ;
@@ -1165,6 +1165,11 @@ namespace ts {
11651165 return buildErrors ( emitDiagnostics , BuildResultFlags . EmitErrors , "Emit" ) ;
11661166 }
11671167
1168+ if ( writeFileName ) {
1169+ emittedOutputs . forEach ( name => listEmittedFile ( configFile , name ) ) ;
1170+ listFiles ( program , writeFileName ) ;
1171+ }
1172+
11681173 // Update time stamps for rest of the outputs
11691174 newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker ( configFile , newestDeclarationFileContentChangedTime , Diagnostics . Updating_unchanged_output_timestamps_of_project_0 , emittedOutputs ) ;
11701175
@@ -1182,13 +1187,21 @@ namespace ts {
11821187 function buildErrors ( diagnostics : ReadonlyArray < Diagnostic > , errorFlags : BuildResultFlags , errorType : string ) {
11831188 resultFlags |= errorFlags ;
11841189 reportAndStoreErrors ( proj , diagnostics ) ;
1190+ // List files if any other build error using program (emit errors already report files)
1191+ if ( writeFileName ) listFiles ( program , writeFileName ) ;
11851192 projectStatus . setValue ( proj , { type : UpToDateStatusType . Unbuildable , reason : `${ errorType } errors` } ) ;
11861193 afterProgramCreate ( proj , program ) ;
11871194 projectCompilerOptions = baseCompilerOptions ;
11881195 return resultFlags ;
11891196 }
11901197 }
11911198
1199+ function listEmittedFile ( proj : ParsedCommandLine , file : string ) {
1200+ if ( writeFileName && proj . options . listEmittedFiles ) {
1201+ writeFileName ( `TSFILE: ${ file } ` ) ;
1202+ }
1203+ }
1204+
11921205 function afterProgramCreate ( proj : ResolvedConfigFileName , program : T ) {
11931206 if ( host . afterProgramEmitAndDiagnostics ) {
11941207 host . afterProgramEmitAndDiagnostics ( program ) ;
@@ -1229,9 +1242,9 @@ namespace ts {
12291242 // Actual Emit
12301243 Debug . assert ( ! ! outputFiles . length ) ;
12311244 const emitterDiagnostics = createDiagnosticCollection ( ) ;
1232- const emittedOutputs = createFileMap < true > ( toPath as ToPath ) ;
1245+ const emittedOutputs = createFileMap < string > ( toPath as ToPath ) ;
12331246 outputFiles . forEach ( ( { name, text, writeByteOrderMark } ) => {
1234- emittedOutputs . setValue ( name , true ) ;
1247+ emittedOutputs . setValue ( name , name ) ;
12351248 writeFile ( compilerHost , emitterDiagnostics , name , text , writeByteOrderMark ) ;
12361249 } ) ;
12371250 const emitDiagnostics = emitterDiagnostics . getDiagnostics ( ) ;
@@ -1242,6 +1255,10 @@ namespace ts {
12421255 return BuildResultFlags . DeclarationOutputUnchanged | BuildResultFlags . EmitErrors ;
12431256 }
12441257
1258+ if ( writeFileName ) {
1259+ emittedOutputs . forEach ( name => listEmittedFile ( config , name ) ) ;
1260+ }
1261+
12451262 // Update timestamps for dts
12461263 const newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker ( config , minimumDate , Diagnostics . Updating_unchanged_output_timestamps_of_project_0 , emittedOutputs ) ;
12471264
@@ -1270,7 +1287,7 @@ namespace ts {
12701287 projectStatus . setValue ( proj . options . configFilePath as ResolvedConfigFilePath , status ) ;
12711288 }
12721289
1273- function updateOutputTimestampsWorker ( proj : ParsedCommandLine , priorNewestUpdateTime : Date , verboseMessage : DiagnosticMessage , skipOutputs ?: FileMap < true > ) {
1290+ function updateOutputTimestampsWorker ( proj : ParsedCommandLine , priorNewestUpdateTime : Date , verboseMessage : DiagnosticMessage , skipOutputs ?: FileMap < string > ) {
12741291 const outputs = getAllProjectOutputs ( proj , ! host . useCaseSensitiveFileNames ( ) ) ;
12751292 if ( ! skipOutputs || outputs . length !== skipOutputs . getSize ( ) ) {
12761293 if ( options . verbose ) {
@@ -1287,9 +1304,7 @@ namespace ts {
12871304 }
12881305
12891306 host . setModifiedTime ( file , now ) ;
1290- if ( proj . options . listEmittedFiles ) {
1291- writeFileName ( `TSFILE: ${ file } ` ) ;
1292- }
1307+ listEmittedFile ( proj , file ) ;
12931308 }
12941309 }
12951310
0 commit comments