restrict-plus-operands
Configuration
rslint.config.ts
Rule Details
Require both operands of addition to be the same type and be bigint, number, or string. The + operator in TypeScript can be used for both addition and string concatenation. This rule ensures that operands of + are both numbers, both bigints, or both strings, preventing accidental implicit type coercions that can lead to unexpected results (e.g., "1" + 2 becoming "12" instead of 3).
Examples of incorrect code for this rule:
Examples of correct code for this rule: