A literal is called, or new is used with an arrow function, which throws

tx0/ts:call-of-non-functiondefaulterrorbug

What it finds

"text"(x), [a, b](0), new (() => {})(), const f = () => 1; new f(): calling a literal throws a TypeError, and so does new with an arrow function, which has no constructor. The first usually comes from a missing operator or semicolon between two lines, the second from turning a function into an arrow.

Reported are calls and tagged templates of string, number, array, object and template literals, and new with an arrow function, written in place or as a const of this file.

From the rule's source, call_of_non_function.rs.

Example from the rule's tests
export function broken(a: number) {  const make = () => ({ a });  const x = "text"(a);tx0 reports: a literal is not a function, so this call throws  const y = new make();tx0 reports: an arrow function cannot be called with new  function Real(this: { a: number }) {}  return [x, y, new (Real as any)()];}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:call-of-non-function" = "off"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/ts:call-of-non-function] reason="..."

tx0 explain tx0/ts:call-of-non-function shows the same in the terminal. Found a false positive? Report it.