From b3c23643c6008964fb3ef853faab5384cdccf5e5 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 21 Dec 2015 15:45:58 -0800 Subject: [PATCH] Add tests --- src/compiler/emitter.ts | 2 +- src/compiler/utilities.ts | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) 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