export default async (x) => x; fails to parse, while Node.js and other engines accept it.
Reproduction
// repro.mjs
export default async (x) => x;
SyntaxError: expected token 'function', got '(' in async function declaration at line 1, col 22
All parenthesised and unparenthesised forms fail:
export default async () => 1; // fails
export default async x => x; // fails
export default async (a, b) => a + b; // fails
Closely related forms that parse fine
This narrows the problem to export default combined with an async arrow:
export default async function (x) { return x; } // ok
const f = async (x) => x; export default f; // ok
export const g = async (x) => x; // ok
Node accepts every failing form above (verified with node --input-type=module).
Spec
export default takes an AssignmentExpression (ExportDeclaration), and AsyncArrowFunction is reachable from it, so these should parse.
Version
main @ 5718cc81111ceff12d6054ab948146a45bc6e114
Found while running a real-world CLI whose command handlers are written as export default async (options) => { … }.
export default async (x) => x;fails to parse, while Node.js and other engines accept it.Reproduction
All parenthesised and unparenthesised forms fail:
Closely related forms that parse fine
This narrows the problem to
export defaultcombined with an async arrow:Node accepts every failing form above (verified with
node --input-type=module).Spec
export defaulttakes an AssignmentExpression (ExportDeclaration), andAsyncArrowFunctionis reachable from it, so these should parse.Version
main@5718cc81111ceff12d6054ab948146a45bc6e114Found while running a real-world CLI whose command handlers are written as
export default async (options) => { … }.