Arithmetic is done with undefined, an object or array literal, or a string that is not a number, which gives NaN

tx0/ts:arithmetic-on-non-numberdefaultwarningreliability/arithmeticdepth fastbug

What it finds

Arithmetic converts its operands to numbers. undefined, object literals and strings such as "abc" convert to NaN, which then spreads through every later computation. With +, objects and arrays are joined as strings instead.

Reported are -, *, /, % and ** with an operand that is undefined, an object or array literal, a function, or a string literal that is not a number, and + with an operand that is undefined and another that is not a string.

From the rule's source, arithmetic_on_non_number.rs.

Example from the rule's tests
export const half = (n: number) => n / "two";tx0 reports: this arithmetic has an operand that converts to NaNexport const fine = (n: number) => n / 2;
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:arithmetic-on-non-number" = "off"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/ts:arithmetic-on-non-number] reason="..."

tx0 explain tx0/ts:arithmetic-on-non-number shows the same in the terminal. Found a false positive? Report it.