diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 818b24ca8fd..8f1c05adabe 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -232,8 +232,8 @@ namespace ts { // Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' export function escapeIdentifier(identifier: string): string { - const prefixWithUnderscore = identifier.length > 2 && identifier.charCodeAt(0) === CharacterCodes._ && identifier.charCodeAt(1) === CharacterCodes._; - return prefixWithUnderscore ? "_" + identifier : identifier; + const prefixedWithUnderscores = identifier.length >= 3 && identifier.charCodeAt(0) === CharacterCodes._ && identifier.charCodeAt(1) === CharacterCodes._; + return prefixedWithUnderscores ? "_" + identifier : identifier; } // Remove extra underscore from escaped identifier