mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
Address PR
This commit is contained in:
parent
62256bd3c6
commit
125d1f448a
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user