mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
feat(codegen): minify class{static[computed]} (#8088)
This commit is contained in:
parent
f873139a0f
commit
fccfda91c1
2 changed files with 30 additions and 12 deletions
|
|
@ -2664,7 +2664,7 @@ impl Gen for MethodDefinition<'_> {
|
|||
p.add_source_mapping(self.span);
|
||||
for decorator in &self.decorators {
|
||||
decorator.print(p, ctx);
|
||||
p.print_hard_space();
|
||||
p.print_soft_space();
|
||||
}
|
||||
if let Some(accessibility) = &self.accessibility {
|
||||
p.print_space_before_identifier();
|
||||
|
|
@ -2742,23 +2742,33 @@ impl Gen for PropertyDefinition<'_> {
|
|||
p.add_source_mapping(self.span);
|
||||
for decorator in &self.decorators {
|
||||
decorator.print(p, ctx);
|
||||
p.print_hard_space();
|
||||
p.print_soft_space();
|
||||
}
|
||||
if self.declare {
|
||||
p.print_str("declare ");
|
||||
p.print_space_before_identifier();
|
||||
p.print_str("declare");
|
||||
p.print_soft_space();
|
||||
}
|
||||
if let Some(accessibility) = self.accessibility {
|
||||
p.print_space_before_identifier();
|
||||
p.print_str(accessibility.as_str());
|
||||
p.print_hard_space();
|
||||
p.print_soft_space();
|
||||
}
|
||||
if self.r#type == PropertyDefinitionType::TSAbstractPropertyDefinition {
|
||||
p.print_str("abstract ");
|
||||
p.print_space_before_identifier();
|
||||
p.print_str("abstract");
|
||||
p.print_soft_space();
|
||||
}
|
||||
if self.r#static {
|
||||
p.print_str("static ");
|
||||
p.print_space_before_identifier();
|
||||
p.add_source_mapping(self.span);
|
||||
p.print_str("static");
|
||||
p.print_soft_space();
|
||||
}
|
||||
if self.readonly {
|
||||
p.print_str("readonly ");
|
||||
p.print_space_before_identifier();
|
||||
p.print_str("readonly");
|
||||
p.print_soft_space();
|
||||
}
|
||||
if self.computed {
|
||||
p.print_ascii_byte(b'[');
|
||||
|
|
@ -2789,18 +2799,26 @@ impl Gen for AccessorProperty<'_> {
|
|||
p.add_source_mapping(self.span);
|
||||
for decorator in &self.decorators {
|
||||
decorator.print(p, ctx);
|
||||
p.print_hard_space();
|
||||
p.print_soft_space();
|
||||
}
|
||||
if self.r#type.is_abstract() {
|
||||
p.print_str("abstract ");
|
||||
p.print_space_before_identifier();
|
||||
p.add_source_mapping(self.span);
|
||||
p.print_str("abstract");
|
||||
p.print_soft_space();
|
||||
}
|
||||
if let Some(accessibility) = self.accessibility {
|
||||
p.print_space_before_identifier();
|
||||
p.print_str(accessibility.as_str());
|
||||
p.print_hard_space();
|
||||
p.print_soft_space();
|
||||
}
|
||||
if self.r#static {
|
||||
p.print_str("static ");
|
||||
p.print_space_before_identifier();
|
||||
p.add_source_mapping(self.span);
|
||||
p.print_str("static");
|
||||
p.print_soft_space();
|
||||
}
|
||||
p.print_space_before_identifier();
|
||||
p.print_str("accessor");
|
||||
if self.computed {
|
||||
p.print_soft_space();
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ fn class() {
|
|||
"export default class Foo { @x @y accessor #aDef = 1 }",
|
||||
"export default class Foo {\n\t@x @y accessor #aDef = 1;\n}\n",
|
||||
);
|
||||
test_minify("class F { static async * foo () {} }", "class F{static async*foo(){}}");
|
||||
test_minify("class { static [computed] }", "class{static[computed]}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in a new issue