Skip to content

Commit 2625c1f

Browse files
authoredOct 20, 2022
Make the init config category order predictable (#51247)
1 parent 1ca99b3 commit 2625c1f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed
 

‎src/compiler/commandLineParser.ts

+14-5
Original file line numberDiff line numberDiff line change
@@ -2582,12 +2582,21 @@ namespace ts {
25822582

25832583
function writeConfigurations() {
25842584
// Filter applicable options to place in the file
2585-
const categorizedOptions = createMultiMap<CommandLineOption>();
2585+
const categorizedOptions = new Map<DiagnosticMessage, CommandLineOption[]>();
2586+
// Set allowed categories in order
2587+
categorizedOptions.set(Diagnostics.Projects, []);
2588+
categorizedOptions.set(Diagnostics.Language_and_Environment, []);
2589+
categorizedOptions.set(Diagnostics.Modules, []);
2590+
categorizedOptions.set(Diagnostics.JavaScript_Support, []);
2591+
categorizedOptions.set(Diagnostics.Emit, []);
2592+
categorizedOptions.set(Diagnostics.Interop_Constraints, []);
2593+
categorizedOptions.set(Diagnostics.Type_Checking, []);
2594+
categorizedOptions.set(Diagnostics.Completeness, []);
25862595
for (const option of optionDeclarations) {
2587-
const { category } = option;
2588-
25892596
if (isAllowedOptionForOutput(option)) {
2590-
categorizedOptions.add(getLocaleSpecificMessage(category!), option);
2597+
let listForCategory = categorizedOptions.get(option.category!);
2598+
if (!listForCategory) categorizedOptions.set(option.category!, listForCategory = []);
2599+
listForCategory.push(option);
25912600
}
25922601
}
25932602

@@ -2599,7 +2608,7 @@ namespace ts {
25992608
if (entries.length !== 0) {
26002609
entries.push({ value: "" });
26012610
}
2602-
entries.push({ value: `/* ${category} */` });
2611+
entries.push({ value: `/* ${getLocaleSpecificMessage(category)} */` });
26032612
for (const option of options) {
26042613
let optionName;
26052614
if (compilerOptionsMap.has(option.name)) {

0 commit comments

Comments
 (0)