Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit fb66f61

Browse files
azzsoda0289
authored andcommitted
Fix: Unescape string literal identifiers (fixes #328) (#330)
1 parent 9cab9d3 commit fb66f61

File tree

3 files changed

+1091
-1
lines changed

3 files changed

+1091
-1
lines changed

lib/convert.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1537,9 +1537,13 @@ module.exports = function convert(config) {
15371537
case SyntaxKind.StringLiteral:
15381538
Object.assign(result, {
15391539
type: AST_NODE_TYPES.Literal,
1540-
value: nodeUtils.unescapeStringLiteralText(node.text),
15411540
raw: ast.text.slice(result.range[0], result.range[1])
15421541
});
1542+
if (parent.name && parent.name === node) {
1543+
result.value = nodeUtils.unescapeIdentifier(node.text);
1544+
} else {
1545+
result.value = nodeUtils.unescapeStringLiteralText(node.text);
1546+
}
15431547
break;
15441548

15451549
case SyntaxKind.NumericLiteral:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
({ '__': null });
2+
3+
({ '__'() {} });
4+
5+
({ ['__']: null });
6+
7+
class X { '__' = null }

0 commit comments

Comments
 (0)