# @typescript-eslint/no-extra-non-null-assertion

> Disallow a non-null assertion that has no effect

`!` after an expression tells TypeScript that the value isn't `null` or `undefined`. Writing it twice, as in `user!!`, doesn't add anything. Writing it right before `?.` contradicts itself, because `user!?.name` first claims that `user` is there and then checks whether it is.

`--fix` removes the extra `!`.

This rule is on by default in TypeScript files.

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

## Configure

On by default as a warning. To turn it off:

```toml bunfig.toml
[lint.rules]
"@typescript-eslint/no-extra-non-null-assertion" = "off" # or "error"
```

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

## Examples

Reported:

{/* bad {"count": 2} */}
```ts
function nameOf(user?: { name: string }) {
  return user!!.name;
}

function lengthOf(items?: string[]) {
  return items!?.length;
}
```

Not reported:

{/* good */}
```ts
function nameOf(user?: { name: string }) {
  return user!.name;
}

function lengthOf(items?: string[]) {
  return items?.length;
}
```
