quick-lint-js

Find bugs in JavaScript programs.

E0254: unexpected ':' in expression; did you mean 'as'?

In TypeScript, : is used to add a type annotation to variables. It is a syntax error to write : in an expression:

interface APIResponse {
  data: object;
  error?: string;
}

let data = await (await fetch(uri)).json(): APIResponse;

To fix this error, write as instead of ::

interface APIResponse {
  data: object;
  error?: string;
}

let data = await (await fetch(uri)).json() as APIResponse;

Documentation for other errors