mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Merge pull request #22981 from a-tarasyuk/bug/advanced-options-do-not-work-with---init
Allow using Advanced_Options with --init
This commit is contained in:
@@ -1341,12 +1341,21 @@ namespace ts {
|
||||
return Array(paddingLength + 1).join(" ");
|
||||
}
|
||||
|
||||
function isAllowedOption({ category, name }: CommandLineOption): boolean {
|
||||
// Skip options which do not have a category or have category `Command_line_Options`
|
||||
// Exclude all possible `Advanced_Options` in tsconfig.json which were NOT defined in command line
|
||||
return category !== undefined
|
||||
&& category !== Diagnostics.Command_line_Options
|
||||
&& (category !== Diagnostics.Advanced_Options || compilerOptionsMap.has(name));
|
||||
}
|
||||
|
||||
function writeConfigurations() {
|
||||
// Filter applicable options to place in the file
|
||||
const categorizedOptions = createMultiMap<CommandLineOption>();
|
||||
for (const option of optionDeclarations) {
|
||||
const { category } = option;
|
||||
if (category !== undefined && category !== Diagnostics.Command_line_Options && category !== Diagnostics.Advanced_Options) {
|
||||
|
||||
if (isAllowedOption(option)) {
|
||||
categorizedOptions.add(getLocaleSpecificMessage(category), option);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,7 @@ namespace ts {
|
||||
initTSConfigCorrectly("Initialized TSConfig with incorrect compiler option", ["--init", "--someNonExistOption"]);
|
||||
|
||||
initTSConfigCorrectly("Initialized TSConfig with incorrect compiler option value", ["--init", "--lib", "nonExistLib,es5,es2015.promise"]);
|
||||
|
||||
initTSConfigCorrectly("Initialized TSConfig with advanced options", ["--init", "--declaration", "--declarationDir", "lib", "--skipLibCheck", "--noErrorTruncation"]);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user