@@ -95,7 +95,7 @@ namespace ts {
95
95
export function formatEnum ( value = 0 , enumObject : any , isFlags ?: boolean ) {
96
96
const members = getEnumMembers ( enumObject ) ;
97
97
if ( value === 0 ) {
98
- return members . length > 0 && members [ 0 ] [ 0 ] === 0 ? members [ 0 ] [ 1 ] : "0" ;
98
+ return members . length > 0 && members [ 0 ] [ 0 ] === 0 ? members [ 0 ] [ 1 ] . join ( "|" ) : "0" ;
99
99
}
100
100
if ( isFlags ) {
101
101
let result = "" ;
@@ -104,7 +104,7 @@ namespace ts {
104
104
const [ enumValue , enumName ] = members [ i ] ;
105
105
if ( enumValue !== 0 && ( remainingFlags & enumValue ) === enumValue ) {
106
106
remainingFlags &= ~ enumValue ;
107
- result = `${ enumName } ${ result ? "|" : "" } ${ result } ` ;
107
+ result = `${ enumName . join ( "|" ) } ${ result ? "|" : "" } ${ result } ` ;
108
108
}
109
109
}
110
110
if ( remainingFlags === 0 ) {
@@ -114,23 +114,25 @@ namespace ts {
114
114
else {
115
115
for ( const [ enumValue , enumName ] of members ) {
116
116
if ( enumValue === value ) {
117
- return enumName ;
117
+ return enumName [ 0 ] ;
118
118
}
119
119
}
120
120
}
121
121
return value . toString ( ) ;
122
122
}
123
123
124
124
function getEnumMembers ( enumObject : any ) {
125
- const result : [ number , string ] [ ] = [ ] ;
125
+ const result = createMultiMap < string > ( ) ;
126
126
for ( const name in enumObject ) {
127
127
const value = enumObject [ name ] ;
128
128
if ( typeof value === "number" ) {
129
- result . push ( [ value , name ] ) ;
129
+ result . add ( "" + value , name ) ;
130
130
}
131
131
}
132
132
133
- return stableSort < [ number , string ] > ( result , ( x , y ) => compareValues ( x [ 0 ] , y [ 0 ] ) ) ;
133
+ return stableSort (
134
+ map ( arrayFrom ( result . entries ( ) ) , ( [ x , y ] ) => [ + x , y ] as const ) ,
135
+ ( x , y ) => compareValues ( x [ 0 ] , y [ 0 ] ) ) ;
134
136
}
135
137
136
138
export function formatSyntaxKind ( kind : SyntaxKind | undefined ) : string {
0 commit comments