Skip to content

Commit c1375d5

Browse files
author
Andy
authored
generateTSConfig: Remove unnecessary variable (#17330)
1 parent eadd084 commit c1375d5

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

src/compiler/commandLineParser.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,15 +1200,7 @@ namespace ts {
12001200
/* @internal */
12011201
export function generateTSConfig(options: CompilerOptions, fileNames: ReadonlyArray<string>, newLine: string): string {
12021202
const compilerOptions = extend(options, defaultInitCompilerOptions);
1203-
const configurations: { compilerOptions: MapLike<CompilerOptionsValue>; files?: ReadonlyArray<string> } = {
1204-
compilerOptions: serializeCompilerOptions(compilerOptions)
1205-
};
1206-
if (fileNames && fileNames.length) {
1207-
// only set the files property if we have at least one file
1208-
configurations.files = fileNames;
1209-
}
1210-
1211-
1203+
const compilerOptionsMap = serializeCompilerOptions(compilerOptions);
12121204
return writeConfigurations();
12131205

12141206
function getCustomTypeMapOfCommandLineOption(optionDefinition: CommandLineOption): Map<string | number> | undefined {
@@ -1306,7 +1298,7 @@ namespace ts {
13061298
let seenKnownKeys = 0;
13071299
const nameColumn: string[] = [];
13081300
const descriptionColumn: string[] = [];
1309-
const knownKeysCount = getOwnKeys(configurations.compilerOptions).length;
1301+
const knownKeysCount = getOwnKeys(compilerOptionsMap).length;
13101302
for (const category in categorizedOptions) {
13111303
if (nameColumn.length !== 0) {
13121304
nameColumn.push("");
@@ -1316,8 +1308,8 @@ namespace ts {
13161308
descriptionColumn.push("");
13171309
for (const option of categorizedOptions[category]) {
13181310
let optionName;
1319-
if (hasProperty(configurations.compilerOptions, option.name)) {
1320-
optionName = `"${option.name}": ${JSON.stringify(configurations.compilerOptions[option.name])}${(seenKnownKeys += 1) === knownKeysCount ? "" : ","}`;
1311+
if (hasProperty(compilerOptionsMap, option.name)) {
1312+
optionName = `"${option.name}": ${JSON.stringify(compilerOptionsMap[option.name])}${(seenKnownKeys += 1) === knownKeysCount ? "" : ","}`;
13211313
}
13221314
else {
13231315
optionName = `// "${option.name}": ${JSON.stringify(getDefaultValueForOption(option))},`;
@@ -1339,11 +1331,11 @@ namespace ts {
13391331
const description = descriptionColumn[i];
13401332
result.push(optionName && `${tab}${tab}${optionName}${ description && (makePadding(marginLength - optionName.length + 2) + description)}`);
13411333
}
1342-
if (configurations.files && configurations.files.length) {
1334+
if (fileNames.length) {
13431335
result.push(`${tab}},`);
13441336
result.push(`${tab}"files": [`);
1345-
for (let i = 0; i < configurations.files.length; i++) {
1346-
result.push(`${tab}${tab}${JSON.stringify(configurations.files[i])}${i === configurations.files.length - 1 ? "" : ","}`);
1337+
for (let i = 0; i < fileNames.length; i++) {
1338+
result.push(`${tab}${tab}${JSON.stringify(fileNames[i])}${i === fileNames.length - 1 ? "" : ","}`);
13471339
}
13481340
result.push(`${tab}]`);
13491341
}

0 commit comments

Comments
 (0)