generateTSConfig: Remove unnecessary variable (#17330)

This commit is contained in:
Andy
2017-07-25 13:30:48 -07:00
committed by GitHub
parent eadd084c82
commit c1375d5422

View File

@@ -1200,15 +1200,7 @@ namespace ts {
/* @internal */
export function generateTSConfig(options: CompilerOptions, fileNames: ReadonlyArray<string>, newLine: string): string {
const compilerOptions = extend(options, defaultInitCompilerOptions);
const configurations: { compilerOptions: MapLike<CompilerOptionsValue>; files?: ReadonlyArray<string> } = {
compilerOptions: serializeCompilerOptions(compilerOptions)
};
if (fileNames && fileNames.length) {
// only set the files property if we have at least one file
configurations.files = fileNames;
}
const compilerOptionsMap = serializeCompilerOptions(compilerOptions);
return writeConfigurations();
function getCustomTypeMapOfCommandLineOption(optionDefinition: CommandLineOption): Map<string | number> | undefined {
@@ -1306,7 +1298,7 @@ namespace ts {
let seenKnownKeys = 0;
const nameColumn: string[] = [];
const descriptionColumn: string[] = [];
const knownKeysCount = getOwnKeys(configurations.compilerOptions).length;
const knownKeysCount = getOwnKeys(compilerOptionsMap).length;
for (const category in categorizedOptions) {
if (nameColumn.length !== 0) {
nameColumn.push("");
@@ -1316,8 +1308,8 @@ namespace ts {
descriptionColumn.push("");
for (const option of categorizedOptions[category]) {
let optionName;
if (hasProperty(configurations.compilerOptions, option.name)) {
optionName = `"${option.name}": ${JSON.stringify(configurations.compilerOptions[option.name])}${(seenKnownKeys += 1) === knownKeysCount ? "" : ","}`;
if (hasProperty(compilerOptionsMap, option.name)) {
optionName = `"${option.name}": ${JSON.stringify(compilerOptionsMap[option.name])}${(seenKnownKeys += 1) === knownKeysCount ? "" : ","}`;
}
else {
optionName = `// "${option.name}": ${JSON.stringify(getDefaultValueForOption(option))},`;
@@ -1339,11 +1331,11 @@ namespace ts {
const description = descriptionColumn[i];
result.push(optionName && `${tab}${tab}${optionName}${ description && (makePadding(marginLength - optionName.length + 2) + description)}`);
}
if (configurations.files && configurations.files.length) {
if (fileNames.length) {
result.push(`${tab}},`);
result.push(`${tab}"files": [`);
for (let i = 0; i < configurations.files.length; i++) {
result.push(`${tab}${tab}${JSON.stringify(configurations.files[i])}${i === configurations.files.length - 1 ? "" : ","}`);
for (let i = 0; i < fileNames.length; i++) {
result.push(`${tab}${tab}${JSON.stringify(fileNames[i])}${i === fileNames.length - 1 ? "" : ","}`);
}
result.push(`${tab}]`);
}