-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[Bug]: babel-traverse path.isForAwaitStatement is broken #14929
Description
💻
- Would you like to work on a fix?
How are you using Babel?
Programmatic API (babel.transform, babel.parse)
Input code
async function x() {
for await (const i of [1, 2, 3]) {
console.log(i);
}
}
x();Configuration file name
No response
Configuration
No response
Current and expected behavior
isForAwaitStatement on the node for the for await statement should return true. It returns false instead, since @babel/traverse@7.19.0.
Environment
System:
OS: macOS 11.5.2
Binaries:
Node: 18.8.0 - /usr/local/bin/node
npm: 8.18.0 - /usr/local/bin/npm
npmPackages:
@babel/core: 7.19.0 => 7.19.0
@babel/plugin-syntax-jsx: 7.18.6 => 7.18.6
@babel/plugin-transform-runtime: 7.18.10 => 7.18.10
@babel/preset-env: 7.19.0 => 7.19.0
@babel/preset-typescript: 7.18.6 => 7.18.6
babel-plugin-transform-async-to-promises: 0.8.16 => 0.8.16
eslint: 8.23.1 => 8.23.1
jest: 28.1.3 => 28.1.3
Possible solution
It seems that it got broken in the refactoring of #14799. I think
babel/packages/babel-traverse/src/path/lib/virtual-types-validator.ts
Lines 199 to 201 in 091ac3d
| export function isForAwaitStatement(this: NodePath): boolean { | |
| return isForStatement(this.node, { await: true }); | |
| } |
isForOfStatement instead of isForStatement.
Additional context
No response