• Error
  • Reported by the type checker

TS2363

The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.

The right operand of `-`, `*`, `/`, `%` or `**` isn't a number, bigint or enum. Convert it first.

What it means

Arithmetic operators other than + need numeric operands. A string, boolean or object on the right is reported.

Example

index.ts
const count = "3";

export const total = 10 * count;
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(3,27): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.

Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.

How to fix

  • Convert explicitly: 10 * Number(count).