Skip to main content


Require unary negation to take a number.


This rule requires type information to run.

TypeScript does not prevent you from putting a minus sign before things other than numbers:

const s = 'hello';
const x = -s; // x is NaN

This rule restricts the unary - operator to number | bigint.

module.exports = {
"rules": {
"@typescript-eslint/no-unsafe-unary-minus": "error"
Try this rule in the playground ↗


❌ Incorrect

declare const a: string;

declare const b: {};

✅ Correct


declare const a: number;

declare const b: number;

declare const c: number | bigint;

declare const d: any;

declare const e: 1 | 2;


This rule is not configurable.