mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-18 01:58:29 -06:00
Add option to list the emitted as part of the compiler output.
This is useful for incremental build scenarios.
This commit is contained in:
parent
3acff6def6
commit
5363b2d7ad
@ -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",
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
};
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user