diff --git a/crates/oxc_codegen/src/gen.rs b/crates/oxc_codegen/src/gen.rs index cf977456fab5e..eb761a5da008b 100644 --- a/crates/oxc_codegen/src/gen.rs +++ b/crates/oxc_codegen/src/gen.rs @@ -2826,6 +2826,7 @@ impl Gen for ObjectPattern<'_> { if let Some(rest) = &self.rest { if !self.properties.is_empty() { p.print_comma(); + p.print_soft_space(); } rest.print(p, ctx); } diff --git a/crates/oxc_codegen/tests/integration/js.rs b/crates/oxc_codegen/tests/integration/js.rs index cfc75c7562c8f..c529f7cba8a84 100644 --- a/crates/oxc_codegen/tests/integration/js.rs +++ b/crates/oxc_codegen/tests/integration/js.rs @@ -12,6 +12,8 @@ fn cases() { #[test] fn decl() { + test_same("const [foo, ...bar] = qux;\n"); + test_same("const { foo, ...bar } = qux;\n"); test_minify("const [foo] = bar", "const[foo]=bar;"); test_minify("const {foo} = bar", "const{foo}=bar;"); test_minify("const foo = bar", "const foo=bar;");