Skip to content

typescript/no-extra-non-null-assertion Correctness

This rule is turned on by default.

What it does

Disallow extra non-null assertions.

Why is this bad?

The ! non-null assertion operator in TypeScript is used to assert that a value's type does not include null or undefined. Using the operator any more than once on a single value does nothing.

Example

ts
const foo: { bar: number } | null = null;
const bar = foo!!!.bar;

References

Released under the MIT License.