diff --git a/crates/oxc_codegen/src/gen.rs b/crates/oxc_codegen/src/gen.rs index da6ffa2ef56f0..20a1ab20d27ee 100644 --- a/crates/oxc_codegen/src/gen.rs +++ b/crates/oxc_codegen/src/gen.rs @@ -2101,6 +2101,7 @@ impl<'a, const MINIFY: bool> GenExpr for NewExpression<'a> { if let Some(comment) = annotate_comment { p.print_comment(comment); } + p.print_space_before_identifier(); p.add_source_mapping(self.span.start); p.print_str("new "); self.callee.gen_expr(p, Precedence::New, Context::FORBID_CALL); diff --git a/crates/oxc_codegen/tests/integration/unit.rs b/crates/oxc_codegen/tests/integration/unit.rs index 5e7372cd9cd52..518bcb8499daf 100644 --- a/crates/oxc_codegen/tests/integration/unit.rs +++ b/crates/oxc_codegen/tests/integration/unit.rs @@ -17,6 +17,7 @@ fn expr() { }", "class Foo {\n\t#test;\n\tbar() {\n\t\tif (!(#test in Foo)) {}\n\t}\n}\n", ); + test_minify("x in new Error()", "x in new Error();"); } #[test]