Urara-Blog/node_modules/.pnpm-store/v3/files/b8/4c34829c2b1418b2bd82aa329aaba72741923be31fb0f3cd9d3372d9a65fede51a5ee4f07bdb47b2ccee04012717c3d87003005d47e74047d227c626104214
2022-08-14 01:14:53 +08:00

64 lines
938 B
Text

---
description: 'Disallow extra non-null assertion.'
---
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/no-extra-non-null-assertion** for documentation.
## Rule Details
Examples of code for this rule:
<!--tabs-->
### ❌ Incorrect
```ts
const foo: { bar: number } | null = null;
const bar = foo!!!.bar;
```
```ts
function foo(bar: number | undefined) {
const bar: number = bar!!!;
}
```
```ts
function foo(bar?: { n: number }) {
return bar!?.n;
}
```
### ✅ Correct
```ts
const foo: { bar: number } | null = null;
const bar = foo!.bar;
```
```ts
function foo(bar: number | undefined) {
const bar: number = bar!;
}
```
```ts
function foo(bar?: { n: number }) {
return bar?.n;
}
```
## Options
```jsonc
// .eslintrc.json
{
"rules": {
"@typescript-eslint/no-extra-non-null-assertion": "error"
}
}
```
This rule is not configurable.