diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-12-10 21:51:33 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-12-10 21:51:33 +0100 |
commit | 0469abd4a9c9270a1fdc962969e36e63699af8b4 (patch) | |
tree | f9864d4a4148621378958794cbbfdc2393733283 /node_modules/tslint/lib/rules/restrictPlusOperandsRule.js | |
parent | 6947e79bbc258f7bc96af424ddb71a511f0c15a3 (diff) |
upgrade dependencies
Diffstat (limited to 'node_modules/tslint/lib/rules/restrictPlusOperandsRule.js')
-rw-r--r-- | node_modules/tslint/lib/rules/restrictPlusOperandsRule.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/node_modules/tslint/lib/rules/restrictPlusOperandsRule.js b/node_modules/tslint/lib/rules/restrictPlusOperandsRule.js index 1974ce47a..c2b8bdb96 100644 --- a/node_modules/tslint/lib/rules/restrictPlusOperandsRule.js +++ b/node_modules/tslint/lib/rules/restrictPlusOperandsRule.js @@ -41,6 +41,7 @@ var Rule = /** @class */ (function (_super) { }; /* tslint:enable:object-literal-sort-keys */ Rule.INVALID_TYPES_ERROR = "Operands of '+' operation must either be both strings or both numbers"; + Rule.SUGGEST_TEMPLATE_LITERALS = ", consider using template literals"; return Rule; }(Lint.Rules.TypedRule)); exports.Rule = Rule; @@ -50,7 +51,12 @@ function walk(ctx, tc) { var leftType = getBaseTypeOfLiteralType(tc.getTypeAtLocation(node.left)); var rightType = getBaseTypeOfLiteralType(tc.getTypeAtLocation(node.right)); if (leftType === "invalid" || rightType === "invalid" || leftType !== rightType) { - return ctx.addFailureAtNode(node, Rule.INVALID_TYPES_ERROR); + if (leftType === "string" || rightType === "string") { + return ctx.addFailureAtNode(node, Rule.INVALID_TYPES_ERROR + Rule.SUGGEST_TEMPLATE_LITERALS); + } + else { + return ctx.addFailureAtNode(node, Rule.INVALID_TYPES_ERROR); + } } } return ts.forEachChild(node, cb); |