diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index d4242725a8d..59482af12e1 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -336,6 +336,10 @@ namespace ts { type: "boolean", description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output }, + { + name: "listEmittedFiles", + type: "boolean" + }, { name: "lib", type: "list", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 422a5562e96..3d0578ac325 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 }; @@ -8233,6 +8235,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 bbe5505b0a0..0c4d6bc8ffb 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1006,7 +1006,7 @@ namespace ts { let declarationDiagnostics: Diagnostic[] = []; if (options.noEmit) { - return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emitSkipped: true }; + return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; } // If the noEmitOnError flag is set, then check if we have any errors so far. If so, @@ -1026,6 +1026,7 @@ namespace ts { return { diagnostics: concatenate(diagnostics, declarationDiagnostics), sourceMaps: undefined, + emittedFiles: undefined, emitSkipped: true }; } diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index f4d25a6bf1b..c2199cf7345 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -14,6 +14,20 @@ namespace ts { } } + function reportEmittedFiles(files: string[], host: CompilerHost): void { + if (!files || files.length == 0) { + return; + } + + const currentDir = sys.getCurrentDirectory(); + + for (const file of files) { + const filepath = getNormalizedAbsolutePath(file, currentDir); + + sys.write(`TSFILE: ${filepath}${sys.newLine}`); + } + } + /** * Checks to see if the locale is in the appropriate format, * and if it is, attempts to set the appropriate language. @@ -108,7 +122,6 @@ namespace ts { sys.write(output); } - const redForegroundEscapeSequence = "\u001b[91m"; const yellowForegroundEscapeSequence = "\u001b[93m"; const blueForegroundEscapeSequence = "\u001b[93m"; @@ -597,6 +610,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 01c841fb8fe..64562260316 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 } @@ -2460,6 +2461,7 @@ namespace ts { allowJs?: boolean; noImplicitUseStrict?: boolean; strictNullChecks?: boolean; + listEmittedFiles?: boolean; lib?: string[]; /* @internal */ stripInternal?: boolean;