Skip to content

Commit ff719f0

Browse files
authoredNov 29, 2023
fix(es/fixer): Wrap yield expression in await expression (#8357)
**Related issue:** - Closes #8356
1 parent 1853280 commit ff719f0

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"jsc": {
3+
"target": "es2017"
4+
}
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const obj = {
2+
async *asyncYield() {
3+
return await (yield* nestedAsyncYield());
4+
},
5+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const obj = {
2+
async *asyncYield () {
3+
return await (yield* nestedAsyncYield());
4+
}
5+
};

‎crates/swc_ecma_transforms_base/src/fixer.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,9 @@ impl VisitMut for Fixer<'_> {
222222
self.ctx = old;
223223

224224
match &*expr.arg {
225-
Expr::Cond(..) | Expr::Assign(..) | Expr::Bin(..) => self.wrap(&mut expr.arg),
225+
Expr::Cond(..) | Expr::Assign(..) | Expr::Bin(..) | Expr::Yield(..) => {
226+
self.wrap(&mut expr.arg)
227+
}
226228
_ => {}
227229
}
228230
}

0 commit comments

Comments
 (0)
Please sign in to comment.