Address PR

This commit is contained in:
Yui T 2016-01-21 16:16:52 -08:00
parent 62256bd3c6
commit 125d1f448a
2 changed files with 2 additions and 3 deletions

View File

@ -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 = <Identifier | LiteralExpression>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)

View File

@ -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