diff --git a/crates/oxc_codegen/src/gen.rs b/crates/oxc_codegen/src/gen.rs index db0255d5b8e9c..078a9cc3600b8 100644 --- a/crates/oxc_codegen/src/gen.rs +++ b/crates/oxc_codegen/src/gen.rs @@ -1996,14 +1996,8 @@ impl Gen for AssignmentTargetPropertyProperty<'_> { PropertyKey::PrivateIdentifier(ident) => { ident.print(p, ctx); } - PropertyKey::StringLiteral(s) => { - if self.computed { - p.print_ascii_byte(b'['); - } + PropertyKey::StringLiteral(s) if !self.computed => { p.print_string_literal(s, /* allow_backtick */ false); - if self.computed { - p.print_ascii_byte(b']'); - } } key => { if self.computed { diff --git a/crates/oxc_codegen/tests/integration/js.rs b/crates/oxc_codegen/tests/integration/js.rs index 3b02879a686d9..154cb2431ecd1 100644 --- a/crates/oxc_codegen/tests/integration/js.rs +++ b/crates/oxc_codegen/tests/integration/js.rs @@ -229,7 +229,7 @@ fn assignment() { test_minify(r#"({"my-key": value} = obj);"#, r#"({"my-key":value}=obj);"#); test_minify( r#"({["computed"]: a, "literal": b} = obj);"#, - r#"({["computed"]:a,"literal":b}=obj);"#, + r#"({[`computed`]:a,"literal":b}=obj);"#, ); test_minify(r#"let {"test-key": testKey} = obj;"#, r#"let{"test-key":testKey}=obj;"#);