quick-lint-js

Find bugs in JavaScript programs.

E0281: TypeScript 'as' type assertions are not allowed in JavaScript

In TypeScript, the as operator is a type assertion which reinterprets a value with a different type at compile time. It is a syntax error to use the as operator in JavaScript code:

let avatar =
  container.querySelector(".avatar") as Image;

To fix this error, remove as and the type:

let avatar = container.querySelector(".avatar");

Alternatively, rename your file to have a .ts or .tsx suffix.

Introduced in quick-lint-js version 2.8.0.

Documentation for other errors