Transform fails on async arrow with rest param inside a conditional expression (VariableDeclarator id got SpreadElement)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.6k
- Forks
- 696
- Avg merge
- 8m
- Merged PRs (30d)
- 7
Description
Description
Bundling a module that contains an async arrow function with a rest parameter and a block body, placed as a branch of a conditional (ternary) expression, fails during Metro's transform step with:
SyntaxError: <file>: Property id of VariableDeclarator expected node to be of
a type ["LVal","VoidPattern"] but instead got "SpreadElement"
This is not a parse error. hermesParser.parse(code, { babel: true }) succeeds on the input; the failure happens later, while Metro's Babel transform processes the hermes-produced AST. It is a @babel/types builder validation, so it carries no source location and Metro prints no code frame.
Minimal reproduction
A module whose entire contents are:
const g = e => (e ? async (...r) => { return r } : 0);
export default { g };
Import it from the entry and bundle for any platform (e.g. npx expo export --platform ios, or metro build). It fails with the error above.
Every one of the following variants bundles fine — all four conditions are required to trigger it:
| Variant | Result |
|---|---|
e ? async (...r) => { return r } : 0 |
❌ fails |
async (...r) => { return r } (no ternary) |
✅ ok |
e ? (...r) => { return r } : 0 (not async) |
✅ ok |
e ? async (...r) => r : 0 (concise body, no block) |
✅ ok |
So the trigger is precisely: async + rest parameter + block body + conditional-expression position.
Regression
The byte-identical input bundles successfully on Metro 0.82.x (Expo SDK 53 / RN 0.79) and fails on Metro 0.84.4 (Expo SDK 56 / RN 0.85.3). Pure toolchain bisect — only the Metro/@react-native/babel-preset/hermes-parser versions changed.
Analysis
hermes-parserparse stage succeeds ({ babel: true }).- The error is thrown from
@babel/typeswhile a transform builds aVariableDeclaratorwhoseidis aSpreadElement— i.e. a node is synthesized incorrectly during theasync-to-generator / parameter handling of the hermes AST. - Likely an interaction between
hermes-parser's Babel AST output and@react-native/babel-preset's async transform, surfacing inmetro-transform-worker.
Environment
metro0.84.4hermes-parser0.33.3react-native0.85.3 (Expo SDK 56.0.9)nodev24.1.0, macOS- Default Metro config (Hermes parser enabled by default,
inlineRequireson)
Expected
The module bundles successfully — the syntax is valid and runs natively on Hermes.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the minimal module from the issue, then trace Metro's transform through metro-transform-worker after hermesParser.parse(code, { babel: true }). Compare the async-transform handling of the four listed variants; done means the triggering module bundles successfully on Metro 0.84.4 without the VariableDeclarator validation error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100