Skip to content

consecutiveNonNullAssertions

Reports unnecessary extra non-null assertions.

✅ This rule is included in the ts logical presets.

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.

AEdeclare consB0val7<2:sp ansty="le--0:#C792EA;--1:#8844">AB0striA7<2|sp ansty="le--0:#C792EA;--1:#8844">AB0nu5<3;d ivclassNa="meec-li">d53valAE!B0toUpperCa53(<);d ivclassNa="meco"><);d>
44AEdeclare co61B0v64<4AE spans="tyle--0:#C5E478;--1:#3B">61B0st4<4AE spans="tyle--0:#7FDBCA;--1:#09">64<4AE spans="tyle--0:#C5E478;--1:#3B">61B03c3F53v4461B0toUpper3F5<3() ;divclass="Name">

This rule is not configurable.

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