Skip to content

Commit e624dff

Browse files
committed
fix(codegen,mangler): do not print shorthand for ObjectProperty (#4350)
I'll fix the TODO's later.
1 parent 21d0eee commit e624dff

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

crates/oxc_codegen/src/gen.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,7 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for ObjectPropertyKind<'a> {
15141514
}
15151515
}
15161516

1517+
// TODO: only print shorthand if key value are the same.
15171518
impl<'a, const MINIFY: bool> Gen<MINIFY> for ObjectProperty<'a> {
15181519
fn gen(&self, p: &mut Codegen<{ MINIFY }>, ctx: Context) {
15191520
if let Expression::FunctionExpression(func) = &self.value {
@@ -1561,16 +1562,12 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for ObjectProperty<'a> {
15611562
if self.computed {
15621563
p.print_char(b'[');
15631564
}
1564-
if !self.shorthand {
1565-
self.key.gen(p, ctx);
1566-
}
1565+
self.key.gen(p, ctx);
15671566
if self.computed {
15681567
p.print_char(b']');
15691568
}
1570-
if !self.shorthand {
1571-
p.print_colon();
1572-
p.print_soft_space();
1573-
}
1569+
p.print_colon();
1570+
p.print_soft_space();
15741571
self.value.gen_expr(p, Precedence::Assign, Context::default());
15751572
}
15761573
}
@@ -2538,7 +2535,7 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for ObjectPattern<'a> {
25382535
}
25392536
}
25402537

2541-
// NOTE: `shorthand` is not printed
2538+
// TODO: only print shorthand if key value are the same.
25422539
impl<'a, const MINIFY: bool> Gen<MINIFY> for BindingProperty<'a> {
25432540
fn gen(&self, p: &mut Codegen<{ MINIFY }>, ctx: Context) {
25442541
p.add_source_mapping(self.span.start);

0 commit comments

Comments
 (0)