Skip to content

Commit d2ae190

Browse files
authored
fix(asi): do not put semi-colon at start of expression stmt body in do while stmt (#545)
1 parent 88c72ba commit d2ae190

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/generation/generate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4543,7 +4543,7 @@ fn gen_namespace_export<'a>(node: &TsNamespaceExportDecl<'a>, context: &mut Cont
45434543
}
45444544

45454545
fn gen_expr_stmt<'a>(stmt: &ExprStmt<'a>, context: &mut Context<'a>) -> PrintItems {
4546-
if context.config.semi_colons.is_true() {
4546+
if context.config.semi_colons.is_true() || stmt.parent().is::<DoWhileStmt>() {
45474547
return gen_inner(stmt, context);
45484548
} else {
45494549
return gen_for_prefix_semi_colon_insertion(stmt, context);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
~~ semiColons: asi ~~
2+
== should not add semi-colon at start ==
3+
do ++x; while (x<10)
4+
5+
[expect]
6+
do ++x
7+
while (x < 10)

0 commit comments

Comments
 (0)