mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
fix(codegen): object shorthand with parens ({x: (x)}) -> ({ x }) (#4391)
This commit is contained in:
parent
e70c67b2e2
commit
44a10c4b91
3 changed files with 3 additions and 2 deletions
|
|
@ -57,7 +57,7 @@ fn main() -> std::io::Result<()> {
|
|||
}
|
||||
let printed = CodeGenerator::new()
|
||||
.enable_comment(
|
||||
&source_text,
|
||||
&printed,
|
||||
ret.trivias.clone(),
|
||||
CommentOptions { preserve_annotate_comments: true },
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1554,7 +1554,7 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for ObjectProperty<'a> {
|
|||
|
||||
let mut shorthand = false;
|
||||
if let PropertyKey::StaticIdentifier(key) = &self.key {
|
||||
if let Expression::Identifier(ident) = &self.value {
|
||||
if let Expression::Identifier(ident) = self.value.without_parenthesized() {
|
||||
if key.name == p.get_identifier_reference_name(ident) {
|
||||
shorthand = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ fn for_stmt() {
|
|||
fn shorthand() {
|
||||
test("let _ = { x }", "let _ = {x};\n");
|
||||
test("let { x } = y", "let { x } = y;\n");
|
||||
test("({ x: (x) })", "({x});\n");
|
||||
test("({ x } = y)", "({x} = y);\n");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue