Skip to content

Commit

Permalink
fix(minifier): { let foo; const bar = undefined; } -> `{ let foo, b…
Browse files Browse the repository at this point in the history
…ar; }`
  • Loading branch information
Boshen committed Jan 28, 2025
1 parent 602becd commit f69501a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/oxc_minifier/src/peephole/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ impl<'a> Normalize {
if all_declarations_are_only_read {
decl.kind = VariableDeclarationKind::Let;
}
for decl in &mut decl.declarations {
decl.kind = VariableDeclarationKind::Let;
}
}
}

Expand Down Expand Up @@ -229,6 +232,7 @@ mod test {
test_same("for (const i = 0; i < 1; i++);");
test_same("for (const x in [1, 2, 3]) x++");
test_same("for (const x of [1, 2, 3]) x++");
test("{ let foo; const bar = undefined; }", "{ let foo, bar; }");
}

#[test]
Expand Down

0 comments on commit f69501a

Please sign in to comment.