File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -230,9 +230,19 @@ namespace ts {
230230 return getSourceTextOfNodeFromSourceFile ( getSourceFileOfNode ( node ) , node , includeTrivia ) ;
231231 }
232232
233+ function prefixWithUnderscoreUnderscore ( identifier : string ) : boolean {
234+ if ( identifier . length <= 2 ) {
235+ return false ;
236+ }
237+ else {
238+ return identifier . charCodeAt ( 0 ) === CharacterCodes . _ && identifier . charCodeAt ( 1 ) === CharacterCodes . _ ? true : false ;
239+ }
240+ }
241+
233242 // Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__'
243+ // TODO(yuisu): comment
234244 export function escapeIdentifier ( identifier : string ) : string {
235- return identifier . length >= 2 && identifier . charCodeAt ( 0 ) === CharacterCodes . _ && identifier . charCodeAt ( 1 ) === CharacterCodes . _ ? "_" + identifier : identifier ;
245+ return prefixWithUnderscoreUnderscore ( identifier ) ? "_" + identifier : identifier ;
236246 }
237247
238248 // Remove extra underscore from escaped identifier
You can’t perform that action at this time.
0 commit comments