quick-lint-js

Find bugs in JavaScript programs.

E0255: missing parentheses around parameter; TypeScript type annotation requires parentheses

Arrow functions with one parameter can omit the parentheses around that parameter. However, if the parameter has a type annotation, it is a syntax error to omit the parentheses:

let friendNames =
  friends.map(f: Friend => f.name);

const toString = thing: string => {
  if (thing === true)  return 'TRUE';
  if (thing === false) return 'FALSE';
  return thing.toString();
};

To fix this error, put a pair of parentheses around the parameter name and its type:

let friendNames =
  friends.map((f: Friend) => f.name);

Alternatively, put a pair of parentheses around the parameter name, and leave the : and the return type outside:

const toString = (thing): string => {
  if (thing === true)  return 'TRUE';
  if (thing === false) return 'FALSE';
  return thing.toString();
};

Documentation for other errors