@@ -1225,8 +1225,8 @@ namespace ts {
1225
1225
} ) ;
1226
1226
}
1227
1227
1228
- function serializeCompilerOptions ( options : CompilerOptions ) : MapLike < CompilerOptionsValue > {
1229
- const result : ts . MapLike < CompilerOptionsValue > = { } ;
1228
+ function serializeCompilerOptions ( options : CompilerOptions ) : Map < CompilerOptionsValue > {
1229
+ const result = createMap < CompilerOptionsValue > ( ) ;
1230
1230
const optionsNameMap = getOptionNameMap ( ) . optionNameMap ;
1231
1231
1232
1232
for ( const name in options ) {
@@ -1243,15 +1243,15 @@ namespace ts {
1243
1243
if ( ! customTypeMap ) {
1244
1244
// There is no map associated with this compiler option then use the value as-is
1245
1245
// This is the case if the value is expect to be string, number, boolean or list of string
1246
- result [ name ] = value ;
1246
+ result . set ( name , value ) ;
1247
1247
}
1248
1248
else {
1249
1249
if ( optionDefinition . type === "list" ) {
1250
- result [ name ] = ( value as ReadonlyArray < string | number > ) . map ( element => getNameOfCompilerOptionValue ( element , customTypeMap ) ) ;
1250
+ result . set ( name , ( value as ReadonlyArray < string | number > ) . map ( element => getNameOfCompilerOptionValue ( element , customTypeMap ) ) ) ;
1251
1251
}
1252
1252
else {
1253
1253
// There is a typeMap associated with this command-line option so use it to map value back to its name
1254
- result [ name ] = getNameOfCompilerOptionValue ( value , customTypeMap ) ;
1254
+ result . set ( name , getNameOfCompilerOptionValue ( value , customTypeMap ) ) ;
1255
1255
}
1256
1256
}
1257
1257
}
@@ -1283,33 +1283,30 @@ namespace ts {
1283
1283
1284
1284
function writeConfigurations ( ) {
1285
1285
// Filter applicable options to place in the file
1286
- const categorizedOptions = reduceLeft (
1287
- filter ( optionDeclarations , o => o . category !== Diagnostics . Command_line_Options && o . category !== Diagnostics . Advanced_Options ) ,
1288
- ( memo , value ) => {
1289
- if ( value . category ) {
1290
- const name = getLocaleSpecificMessage ( value . category ) ;
1291
- ( memo [ name ] || ( memo [ name ] = [ ] ) ) . push ( value ) ;
1292
- }
1293
- return memo ;
1294
- } , < MapLike < CommandLineOption [ ] > > { } ) ;
1286
+ const categorizedOptions = createMultiMap < CommandLineOption > ( ) ;
1287
+ for ( const option of optionDeclarations ) {
1288
+ const { category } = option ;
1289
+ if ( category !== undefined && category !== Diagnostics . Command_line_Options && category !== Diagnostics . Advanced_Options ) {
1290
+ categorizedOptions . add ( getLocaleSpecificMessage ( category ) , option ) ;
1291
+ }
1292
+ }
1295
1293
1296
- // Serialize all options and thier descriptions
1294
+ // Serialize all options and their descriptions
1297
1295
let marginLength = 0 ;
1298
1296
let seenKnownKeys = 0 ;
1299
1297
const nameColumn : string [ ] = [ ] ;
1300
1298
const descriptionColumn : string [ ] = [ ] ;
1301
- const knownKeysCount = getOwnKeys ( compilerOptionsMap ) . length ;
1302
- for ( const category in categorizedOptions ) {
1299
+ categorizedOptions . forEach ( ( options , category ) => {
1303
1300
if ( nameColumn . length !== 0 ) {
1304
1301
nameColumn . push ( "" ) ;
1305
1302
descriptionColumn . push ( "" ) ;
1306
1303
}
1307
1304
nameColumn . push ( `/* ${ category } */` ) ;
1308
1305
descriptionColumn . push ( "" ) ;
1309
- for ( const option of categorizedOptions [ category ] ) {
1306
+ for ( const option of options ) {
1310
1307
let optionName ;
1311
- if ( hasProperty ( compilerOptionsMap , option . name ) ) {
1312
- optionName = `"${ option . name } ": ${ JSON . stringify ( compilerOptionsMap [ option . name ] ) } ${ ( seenKnownKeys += 1 ) === knownKeysCount ? "" : "," } ` ;
1308
+ if ( compilerOptionsMap . has ( option . name ) ) {
1309
+ optionName = `"${ option . name } ": ${ JSON . stringify ( compilerOptionsMap . get ( option . name ) ) } ${ ( seenKnownKeys += 1 ) === compilerOptionsMap . size ? "" : "," } ` ;
1313
1310
}
1314
1311
else {
1315
1312
optionName = `// "${ option . name } ": ${ JSON . stringify ( getDefaultValueForOption ( option ) ) } ,` ;
@@ -1318,7 +1315,7 @@ namespace ts {
1318
1315
descriptionColumn . push ( `/* ${ option . description && getLocaleSpecificMessage ( option . description ) || option . name } */` ) ;
1319
1316
marginLength = Math . max ( optionName . length , marginLength ) ;
1320
1317
}
1321
- }
1318
+ } ) ;
1322
1319
1323
1320
// Write the output
1324
1321
const tab = makePadding ( 2 ) ;
0 commit comments