diff options
Diffstat (limited to 'node_modules/tslint/lib/rules/noStringLiteralRule.js')
-rw-r--r-- | node_modules/tslint/lib/rules/noStringLiteralRule.js | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/node_modules/tslint/lib/rules/noStringLiteralRule.js b/node_modules/tslint/lib/rules/noStringLiteralRule.js index 7774cbcb2..c543aa4d8 100644 --- a/node_modules/tslint/lib/rules/noStringLiteralRule.js +++ b/node_modules/tslint/lib/rules/noStringLiteralRule.js @@ -50,9 +50,11 @@ function walk(ctx) { if (tsutils_1.isElementAccessExpression(node)) { var argument = node.argumentExpression; if (argument !== undefined && tsutils_1.isStringLiteral(argument) && tsutils_1.isValidPropertyAccess(argument.text)) { + // for compatibility with typescript@<2.5.0 to avoid fixing expr['__foo'] to expr.___foo + var propertyName = ts.unescapeIdentifier(argument.text); // tslint:disable-line:deprecation ctx.addFailureAtNode(argument, Rule.FAILURE_STRING, // expr['foo'] -> expr.foo - Lint.Replacement.replaceFromTo(node.expression.end, node.end, "." + argument.text)); + Lint.Replacement.replaceFromTo(node.expression.end, node.end, "." + propertyName)); } } return ts.forEachChild(node, cb); |