From 2625c1feae25aede35465ca835440fc57bf13d52 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 20 Oct 2022 13:23:18 -0700 Subject: [PATCH] Make the init config category order predictable (#51247) --- src/compiler/commandLineParser.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index b3dcb04c777d9..d13f8156e43e3 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -2582,12 +2582,21 @@ namespace ts { function writeConfigurations() { // Filter applicable options to place in the file - const categorizedOptions = createMultiMap(); + const categorizedOptions = new Map(); + // Set allowed categories in order + categorizedOptions.set(Diagnostics.Projects, []); + categorizedOptions.set(Diagnostics.Language_and_Environment, []); + categorizedOptions.set(Diagnostics.Modules, []); + categorizedOptions.set(Diagnostics.JavaScript_Support, []); + categorizedOptions.set(Diagnostics.Emit, []); + categorizedOptions.set(Diagnostics.Interop_Constraints, []); + categorizedOptions.set(Diagnostics.Type_Checking, []); + categorizedOptions.set(Diagnostics.Completeness, []); for (const option of optionDeclarations) { - const { category } = option; - if (isAllowedOptionForOutput(option)) { - categorizedOptions.add(getLocaleSpecificMessage(category!), option); + let listForCategory = categorizedOptions.get(option.category!); + if (!listForCategory) categorizedOptions.set(option.category!, listForCategory = []); + listForCategory.push(option); } } @@ -2599,7 +2608,7 @@ namespace ts { if (entries.length !== 0) { entries.push({ value: "" }); } - entries.push({ value: `/* ${category} */` }); + entries.push({ value: `/* ${getLocaleSpecificMessage(category)} */` }); for (const option of options) { let optionName; if (compilerOptionsMap.has(option.name)) {