quick-lint-js

Find bugs in JavaScript programs.

E0261: TypeScript non-null assertions are not allowed in JavaScript

In TypeScript, ! after a expression is a non-null assertion. It is a syntax error to write a non-null assertion in JavaScript:

/** @type {string} favoritePowerRanger */
let favoritePowerRanger;
if (player.hasFavoriteColor) {
  favoritePowerRanger = player.favoriteColor!;
} else {
  favoritePowerRanger = "(unknown)";
}

To fix this error, remove the !:

/** @type {string} favoritePowerRanger */
let favoritePowerRanger;
if (player.hasFavoriteColor) {
  favoritePowerRanger = player.favoriteColor;
} else {
  favoritePowerRanger = "(unknown)";
}

Introduced in quick-lint-js version 2.7.0.

Documentation for other errors