Bug Report
🔎 Search Terms
for await return next throw
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
Playground link with relevant code
💻 Code
let pass = true
async function f() {
const y = {
[Symbol.asyncIterator]() {
let count = 0
return {
async next() {
count++
if (count === 2) throw 'error'
return { value: count }
},
async return() {
pass = false
},
}
},
}
for await (let x of y) {
}
}
f().catch(() => console.log({ pass }))
🙁 Actual behavior
The code prints { pass: false } when transformed by TypeScript with target ES2017 or lower.
🙂 Expected behavior
The code prints { pass: true } when run natively and when transformed by Babel. I discovered this behavior difference when investigating doing a similar transform for esbuild.
Bug Report
🔎 Search Terms
for await return next throw
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
The code prints
{ pass: false }when transformed by TypeScript with targetES2017or lower.🙂 Expected behavior
The code prints
{ pass: true }when run natively and when transformed by Babel. I discovered this behavior difference when investigating doing a similar transform for esbuild.