Skip to content

7$: Improve error message for 'await () => {}' #278

Closed
@strager

Description

@strager

Often, I accidentally type 'await' instead of 'async' for my async arrow functions:

function g() {
  f(await () => {
    await x;
  });
}

quick-lint-js reports errors for both await( and await x:

hello.js:3:5: error: 'await' is only allowed in async functions [E162]
hello.js:2:5: error: missing operator between expression and arrow function [E063]
hello.js:2:5: warning: use of undeclared variable: await [E057]

quick-lint-js should infer that async was intended, and provide a better error message (see below) and better error recovery (by assuming that the arrow function is async):

hello.js:2:5: error: 'await' does not create an async arrow function; use 'async' instead [E???]

Metadata

Metadata

Assignees

Labels

for hireGet paid for working on this task: https://quick-lint-js.com/hiring.html

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions