Skip to content

Commit

Permalink
Replace functions with declare in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
samestep committed Oct 29, 2023
1 parent bc0430f commit 86b634a
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions packages/eslint-plugin/docs/rules/no-unsafe-unary-minus.md
Expand Up @@ -20,18 +20,31 @@ This rule restricts the unary `-` operator to `number | bigint`.
### ❌ Incorrect

```ts
const f = (a: string) => -a;
const g = (a: {}) => -a;
declare const a: string;
-a;

declare const b: {};
-b;
```

### ✅ Correct

```ts
const a = -42;
const b = -42n;
const f1 = (a: number) => -a;
const f2 = (a: bigint) => -a;
const f3 = (a: number | bigint) => -a;
const f4 = (a: any) => -a;
const f5 = (a: 1 | 2) => -a;
-42;
-42n;

declare const a: number;
-a;

declare const b: number;
-b;

declare const c: number | bigint;
-c;

declare const d: any;
-d;

declare const e: 1 | 2;
-e;
```

0 comments on commit 86b634a

Please sign in to comment.