Skip to content

consecutiveNonNullAssertions

Reports unnecessary extra non-null assertions.

✅ This rule is included in the ts logical preset.

The non-null assertion operator (!) is used to assert that a value is not null or undefined. Using it multiple times in a row does not do anything, and just takes up space unnecessarily.

declare const value: string | null;
value!!.toUpperCase();

This rule is not configurable.

There are no situations where it is beneficial to include extra chains of !!s.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.