From e787e9d41a9b6cc1358f6d4985cdfaa6ddafb697 Mon Sep 17 00:00:00 2001 From: Boshen <1430279+Boshen@users.noreply.github.com> Date: Wed, 4 Dec 2024 06:43:32 +0000 Subject: [PATCH] fix(codegen): print parentheses correctly for ClassHeritage (#7637) closes #7631 --- crates/oxc_codegen/src/gen.rs | 2 +- crates/oxc_codegen/tests/integration/esbuild.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/oxc_codegen/src/gen.rs b/crates/oxc_codegen/src/gen.rs index 68beb55714ebd..df564fb229d06 100644 --- a/crates/oxc_codegen/src/gen.rs +++ b/crates/oxc_codegen/src/gen.rs @@ -2185,7 +2185,7 @@ impl Gen for Class<'_> { } if let Some(super_class) = self.super_class.as_ref() { p.print_str(" extends "); - super_class.print_expr(p, Precedence::Call, Context::empty()); + super_class.print_expr(p, Precedence::Postfix, Context::empty()); if let Some(super_type_parameters) = &self.super_type_parameters { super_type_parameters.print(p, ctx); } diff --git a/crates/oxc_codegen/tests/integration/esbuild.rs b/crates/oxc_codegen/tests/integration/esbuild.rs index 7dc42d806ecea..9ae5e68b17ecc 100644 --- a/crates/oxc_codegen/tests/integration/esbuild.rs +++ b/crates/oxc_codegen/tests/integration/esbuild.rs @@ -615,6 +615,8 @@ fn test_class() { test("class Foo { static foo() {} }", "class Foo {\n\tstatic foo() {}\n}\n"); test("class Foo { static get foo() {} }", "class Foo {\n\tstatic get foo() {}\n}\n"); test("class Foo { static set foo(x) {} }", "class Foo {\n\tstatic set foo(x) {}\n}\n"); + + test("class Foo extends foo() {}", "class Foo extends foo() {}\n"); } #[test]