fix(codegen): fix whitespace issue when minifying x in new Error() (#4886)

This commit is contained in:
Boshen 2024-08-14 04:29:17 +00:00
parent c164bb8b64
commit e8de4bde41
2 changed files with 2 additions and 0 deletions

View file

@ -2101,6 +2101,7 @@ impl<'a, const MINIFY: bool> GenExpr<MINIFY> 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);

View file

@ -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]