目录

@typescript-eslint/restrict-plus-operands

Require both operands of addition to be the same type and be bigint, number, or string.

Rule Configuration

// code-linter.json5
{
  "rules": {
    "@typescript-eslint/restrict-plus-operands": "error"
  }
}

Options

For details, see @typescript-eslint/restrict-plus-operands.

Example of Correct Code

const num = 10;
const bigIntNum = 1n;
export const foo1 = parseInt('5.5', num) + num;
export const foo2 = bigIntNum + bigIntNum;

Example of Incorrect Code

const num = 10;
const bigIntNum = 1n;
export const foo2 = bigIntNum + num;

Rule Set

plugin:@typescript-eslint/all

For details about how to configure Code Linter check rules, see Code Linter.