Closed
Description
🔎 Search Terms
"for loop", "array literal", "array binding pattern"
🕗 Version & Regression Information
- This changed between versions ______ and _______
- This changed in commit or PR _______
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about for loops
- I was unable to test this on prior versions because _______
⏯ Playground Link
💻 Code
let first, second;
for ([first, second] of [[1,2],[3,4]]) {
console.log(first, second);
}
🙁 Actual behavior
The [first, second]
expression in the example's for ... of
loop is mapped to a ts.ArrayLiteral
which gets assigned to the ts.ForOfStatement
's initalizer
property.
🙂 Expected behavior
Even though the variables are declared before the loop, I would have expected to see a ts.ArrayBindingPattern
node in the AST.
Additional information about the issue
The same is true for object binding patterns, which get mapped to ts.ObjectLiteralExpression
s rather than a ts.ObjectBindingPattern
.