@@ -394,7 +394,7 @@ namespace ts {
394
394
const projectStatus = createFileMap < UpToDateStatus > ( toPath ) ;
395
395
const missingRoots = createMap < true > ( ) ;
396
396
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 ;
398
398
let readFileWithCache = ( f : string ) => host . readFile ( f ) ;
399
399
let projectCompilerOptions = baseCompilerOptions ;
400
400
const compilerHost = createCompilerHostFromProgramHost ( host , ( ) => projectCompilerOptions ) ;
@@ -1129,7 +1129,7 @@ namespace ts {
1129
1129
let declDiagnostics : Diagnostic [ ] | undefined ;
1130
1130
const reportDeclarationDiagnostics = ( d : Diagnostic ) => ( declDiagnostics || ( declDiagnostics = [ ] ) ) . push ( d ) ;
1131
1131
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 } ) ) ;
1133
1133
// Don't emit .d.ts if there are decl file errors
1134
1134
if ( declDiagnostics ) {
1135
1135
program . restoreState ( ) ;
@@ -1138,7 +1138,7 @@ namespace ts {
1138
1138
1139
1139
// Actual Emit
1140
1140
const emitterDiagnostics = createDiagnosticCollection ( ) ;
1141
- const emittedOutputs = createFileMap < true > ( toPath as ToPath ) ;
1141
+ const emittedOutputs = createFileMap < string > ( toPath as ToPath ) ;
1142
1142
outputFiles . forEach ( ( { name, text, writeByteOrderMark } ) => {
1143
1143
let priorChangeTime : Date | undefined ;
1144
1144
if ( ! anyDtsChanged && isDeclarationFile ( name ) ) {
@@ -1152,7 +1152,7 @@ namespace ts {
1152
1152
}
1153
1153
}
1154
1154
1155
- emittedOutputs . setValue ( name , true ) ;
1155
+ emittedOutputs . setValue ( name , name ) ;
1156
1156
writeFile ( compilerHost , emitterDiagnostics , name , text , writeByteOrderMark ) ;
1157
1157
if ( priorChangeTime !== undefined ) {
1158
1158
newestDeclarationFileContentChangedTime = newer ( priorChangeTime , newestDeclarationFileContentChangedTime ) ;
@@ -1165,6 +1165,11 @@ namespace ts {
1165
1165
return buildErrors ( emitDiagnostics , BuildResultFlags . EmitErrors , "Emit" ) ;
1166
1166
}
1167
1167
1168
+ if ( writeFileName ) {
1169
+ emittedOutputs . forEach ( name => listEmittedFile ( configFile , name ) ) ;
1170
+ listFiles ( program , writeFileName ) ;
1171
+ }
1172
+
1168
1173
// Update time stamps for rest of the outputs
1169
1174
newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker ( configFile , newestDeclarationFileContentChangedTime , Diagnostics . Updating_unchanged_output_timestamps_of_project_0 , emittedOutputs ) ;
1170
1175
@@ -1182,13 +1187,21 @@ namespace ts {
1182
1187
function buildErrors ( diagnostics : ReadonlyArray < Diagnostic > , errorFlags : BuildResultFlags , errorType : string ) {
1183
1188
resultFlags |= errorFlags ;
1184
1189
reportAndStoreErrors ( proj , diagnostics ) ;
1190
+ // List files if any other build error using program (emit errors already report files)
1191
+ if ( writeFileName ) listFiles ( program , writeFileName ) ;
1185
1192
projectStatus . setValue ( proj , { type : UpToDateStatusType . Unbuildable , reason : `${ errorType } errors` } ) ;
1186
1193
afterProgramCreate ( proj , program ) ;
1187
1194
projectCompilerOptions = baseCompilerOptions ;
1188
1195
return resultFlags ;
1189
1196
}
1190
1197
}
1191
1198
1199
+ function listEmittedFile ( proj : ParsedCommandLine , file : string ) {
1200
+ if ( writeFileName && proj . options . listEmittedFiles ) {
1201
+ writeFileName ( `TSFILE: ${ file } ` ) ;
1202
+ }
1203
+ }
1204
+
1192
1205
function afterProgramCreate ( proj : ResolvedConfigFileName , program : T ) {
1193
1206
if ( host . afterProgramEmitAndDiagnostics ) {
1194
1207
host . afterProgramEmitAndDiagnostics ( program ) ;
@@ -1229,9 +1242,9 @@ namespace ts {
1229
1242
// Actual Emit
1230
1243
Debug . assert ( ! ! outputFiles . length ) ;
1231
1244
const emitterDiagnostics = createDiagnosticCollection ( ) ;
1232
- const emittedOutputs = createFileMap < true > ( toPath as ToPath ) ;
1245
+ const emittedOutputs = createFileMap < string > ( toPath as ToPath ) ;
1233
1246
outputFiles . forEach ( ( { name, text, writeByteOrderMark } ) => {
1234
- emittedOutputs . setValue ( name , true ) ;
1247
+ emittedOutputs . setValue ( name , name ) ;
1235
1248
writeFile ( compilerHost , emitterDiagnostics , name , text , writeByteOrderMark ) ;
1236
1249
} ) ;
1237
1250
const emitDiagnostics = emitterDiagnostics . getDiagnostics ( ) ;
@@ -1242,6 +1255,10 @@ namespace ts {
1242
1255
return BuildResultFlags . DeclarationOutputUnchanged | BuildResultFlags . EmitErrors ;
1243
1256
}
1244
1257
1258
+ if ( writeFileName ) {
1259
+ emittedOutputs . forEach ( name => listEmittedFile ( config , name ) ) ;
1260
+ }
1261
+
1245
1262
// Update timestamps for dts
1246
1263
const newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker ( config , minimumDate , Diagnostics . Updating_unchanged_output_timestamps_of_project_0 , emittedOutputs ) ;
1247
1264
@@ -1270,7 +1287,7 @@ namespace ts {
1270
1287
projectStatus . setValue ( proj . options . configFilePath as ResolvedConfigFilePath , status ) ;
1271
1288
}
1272
1289
1273
- function updateOutputTimestampsWorker ( proj : ParsedCommandLine , priorNewestUpdateTime : Date , verboseMessage : DiagnosticMessage , skipOutputs ?: FileMap < true > ) {
1290
+ function updateOutputTimestampsWorker ( proj : ParsedCommandLine , priorNewestUpdateTime : Date , verboseMessage : DiagnosticMessage , skipOutputs ?: FileMap < string > ) {
1274
1291
const outputs = getAllProjectOutputs ( proj , ! host . useCaseSensitiveFileNames ( ) ) ;
1275
1292
if ( ! skipOutputs || outputs . length !== skipOutputs . getSize ( ) ) {
1276
1293
if ( options . verbose ) {
@@ -1287,9 +1304,7 @@ namespace ts {
1287
1304
}
1288
1305
1289
1306
host . setModifiedTime ( file , now ) ;
1290
- if ( proj . options . listEmittedFiles ) {
1291
- writeFileName ( `TSFILE: ${ file } ` ) ;
1292
- }
1307
+ listEmittedFile ( proj , file ) ;
1293
1308
}
1294
1309
}
1295
1310
0 commit comments