From 125d1f448a2502f004cf553acfd1a0bfc4139782 Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 21 Jan 2016 16:16:52 -0800 Subject: [PATCH] Address PR --- src/compiler/emitter.ts | 2 +- src/compiler/utilities.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 0caff291b60..cc4cec5895f 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -3848,7 +3848,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // 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); - // We need to escape identifier here because when parsing an identifier prefixing with "__" + // We need to unescape identifier here because when parsing an identifier prefixing with "__" // the parser need to append "_" in order to escape colliding with magic identifiers such as "__proto__" // Therefore, in order to correctly emit identifiers that are written in original TypeScript file, // we will unescapeIdentifier to remove additional underscore (if no underscore is added, the function will return original input string) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 0beabe4b9ea..7bc708c7178 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -232,8 +232,7 @@ 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 prefixedWithUnderscores = identifier.length >= 3 && identifier.charCodeAt(0) === CharacterCodes._ && identifier.charCodeAt(1) === CharacterCodes._; - return prefixedWithUnderscores ? "_" + identifier : identifier; + return identifier.length >= 2 && identifier.charCodeAt(0) === CharacterCodes._ && identifier.charCodeAt(1) === CharacterCodes._ ? "_" + identifier : identifier; } // Remove extra underscore from escaped identifier