# @typescript-eslint/no-unsafe-unary-minus

> Require the operand of unary `-` to be a number or a bigint

`-value` converts `value` to a number first. For a string that isn't numeric, an object, or an array with several items, the result is `NaN`. TypeScript accepts it without an error.

A union is reported if any of its members isn't a number or a bigint. `any` isn't reported.

`bun lint --type-aware` turns this rule on in TypeScript files.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. This rule needs types, so turning it on makes `bun lint` type check your code first.

```toml bunfig.toml
[lint.rules]
"@typescript-eslint/no-unsafe-unary-minus" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```ts
function refund(amount: string) {
  return -amount;
}
```

{/* bad */}
```ts
function flip(offset: number | string) {
  return -offset;
}
```

Not reported:

{/* good */}
```ts
function refund(amount: string) {
  return -Number(amount);
}

function flip(offset: number | bigint) {
  return -offset;
}
```
