diff options
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); |