diff --git a/crates/oxc_codegen/src/gen.rs b/crates/oxc_codegen/src/gen.rs index 03f390a9e95ec..7d5aee94b09d6 100644 --- a/crates/oxc_codegen/src/gen.rs +++ b/crates/oxc_codegen/src/gen.rs @@ -2158,16 +2158,16 @@ impl<'a> Gen for MetaProperty<'a> { impl<'a> Gen for Class<'a> { fn gen(&self, p: &mut Codegen, ctx: Context) { p.add_source_mapping(self.span.start); - if self.declare { - p.print_str("declare "); - } - if self.r#abstract { - p.print_str("abstract "); - } let n = p.code_len(); let wrap = self.is_expression() && (p.start_of_stmt == n || p.start_of_default_export == n); p.wrap(wrap, |p| { self.decorators.gen(p, ctx); + if self.declare { + p.print_str("declare "); + } + if self.r#abstract { + p.print_str("abstract "); + } p.print_str("class"); if let Some(id) = &self.id { p.print_hard_space(); diff --git a/crates/oxc_codegen/tests/integration/snapshots/ts.snap b/crates/oxc_codegen/tests/integration/snapshots/ts.snap index a4eaa09690546..5584266fafe65 100644 --- a/crates/oxc_codegen/tests/integration/snapshots/ts.snap +++ b/crates/oxc_codegen/tests/integration/snapshots/ts.snap @@ -106,3 +106,6 @@ c = foo; d = x satisfies y; d = ((x) satisfies y); + +export @x declare abstract class C {} +export @x declare abstract class C {} diff --git a/crates/oxc_codegen/tests/integration/ts.rs b/crates/oxc_codegen/tests/integration/ts.rs index 326e0da8efc09..7944aae11295a 100644 --- a/crates/oxc_codegen/tests/integration/ts.rs +++ b/crates/oxc_codegen/tests/integration/ts.rs @@ -50,6 +50,7 @@ fn ts() { "b = (x as y);", "c = foo;", "d = x satisfies y;", + "export @x declare abstract class C {}", ]; let snapshot = cases.into_iter().fold(String::new(), |mut w, case| {