diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 67a3e264efc..3ee27ae255d 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -331,6 +331,11 @@ namespace ts { type: "boolean", description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output }, + { + name: "listEmittedFiles", + type: "boolean", + description: Diagnostics.List_emitted_files + }, { name: "lib", type: "list", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8fefa92b140..f230d366cdb 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2292,6 +2292,10 @@ "category": "Message", "code": 6011 }, + "List emitted files.": { + "category": "Message", + "code": 6012 + }, "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015'": { "category": "Message", "code": 6015 diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 469530bb6be..0852f76ef2a 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -380,6 +380,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge const languageVersion = getEmitScriptTarget(compilerOptions); const modulekind = getEmitModuleKind(compilerOptions); const sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; + const emittedFilesList: string[] = compilerOptions.listEmittedFiles ? [] : undefined; const emitterDiagnostics = createDiagnosticCollection(); let emitSkipped = false; const newLine = host.getNewLine(); @@ -390,6 +391,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge return { emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), + emittedFiles: emittedFilesList, sourceMaps: sourceMapDataList }; @@ -8232,6 +8234,16 @@ const _super = (function (geti, seti) { if (declarationFilePath) { emitSkipped = writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics) || emitSkipped; } + + if (!emitSkipped && emittedFilesList) { + emittedFilesList.push(jsFilePath); + if (sourceMapFilePath) { + emittedFilesList.push(sourceMapFilePath); + } + if (declarationFilePath) { + emittedFilesList.push(declarationFilePath); + } + } } } } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 70c421f9d2b..056b2a4fc9a 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1015,7 +1015,7 @@ namespace ts { let declarationDiagnostics: Diagnostic[] = []; if (options.noEmit) { - return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emitSkipped: true }; + return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: [], emitSkipped: true }; } // If the noEmitOnError flag is set, then check if we have any errors so far. If so, @@ -1035,6 +1035,7 @@ namespace ts { return { diagnostics: concatenate(diagnostics, declarationDiagnostics), sourceMaps: undefined, + emittedFiles: [], emitSkipped: true }; } diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index f4d25a6bf1b..198b59af2dd 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -14,6 +14,17 @@ namespace ts { } } + function reportEmittedFiles(files: string[], host: CompilerHost): void { + if (!files || files.length == 0) { + return; + } + + for (const file of files) { + const message = `TSFILE: ${file}${sys.newLine}`; + sys.write(message); + } + } + /** * Checks to see if the locale is in the appropriate format, * and if it is, attempts to set the appropriate language. @@ -108,7 +119,6 @@ namespace ts { sys.write(output); } - const redForegroundEscapeSequence = "\u001b[91m"; const yellowForegroundEscapeSequence = "\u001b[93m"; const blueForegroundEscapeSequence = "\u001b[93m"; @@ -130,7 +140,7 @@ namespace ts { let output = ""; if (diagnostic.file) { - const { start, length, file } = diagnostic; + const {start, length, file} = diagnostic; const { line: firstLine, character: firstLineChar } = getLineAndCharacterOfPosition(file, start); const { line: lastLine, character: lastLineChar } = getLineAndCharacterOfPosition(file, start + length); const lastLineInFile = getLineAndCharacterOfPosition(file, file.text.length).line; @@ -185,7 +195,7 @@ namespace ts { } output += sys.newLine; - output += `${ relativeFileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `; + output += `${relativeFileName}(${firstLine + 1},${firstLineChar + 1}): `; } const categoryColor = categoryFormatMap[diagnostic.category]; @@ -597,6 +607,8 @@ namespace ts { reportDiagnostics(sortAndDeduplicateDiagnostics(diagnostics), compilerHost); + reportEmittedFiles(emitOutput.emittedFiles, compilerHost); + if (emitOutput.emitSkipped && diagnostics.length > 0) { // If the emitter didn't emit anything, then pass that value along. return ExitStatus.DiagnosticsPresent_OutputsSkipped; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 3bc3d1ad6a1..f8dd5627148 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1709,6 +1709,7 @@ namespace ts { emitSkipped: boolean; /** Contains declaration emit diagnostics */ diagnostics: Diagnostic[]; + emittedFiles: string[]; // Array of files the compiler wrote to disk /* @internal */ sourceMaps: SourceMapData[]; // Array of sourceMapData if compiler emitted sourcemaps } @@ -2458,6 +2459,7 @@ namespace ts { allowJs?: boolean; noImplicitUseStrict?: boolean; strictNullChecks?: boolean; + listEmittedFiles?: boolean; lib?: string[]; /* @internal */ stripInternal?: boolean;