diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index a3fb38d32c8..512ab883e17 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -3889,7 +3889,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge // We create a synthetic copy of the identifier in order to avoid the rewriting that might // otherwise occur when the identifier is emitted. index = createSynthesizedNode(propName.kind); - (index).text = (propName).text; + (index).text = unescapeIdentifier((propName).text); } return !nameIsComputed && index.kind === SyntaxKind.Identifier diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index a32cbc505a3..2ea1b989eba 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -238,11 +238,10 @@ namespace ts { return identifier.charCodeAt(0) === CharacterCodes._ && identifier.charCodeAt(1) === CharacterCodes._ ? true : false; } } - + // Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' - // TODO(yuisu): comment export function escapeIdentifier(identifier: string): string { - return prefixWithUnderscoreUnderscore(identifier)? "_" + identifier : identifier; + return prefixWithUnderscoreUnderscore(identifier) ? "_" + identifier : identifier; } // Remove extra underscore from escaped identifier