diff --git a/crates/oxc_codegen/src/gen.rs b/crates/oxc_codegen/src/gen.rs index a4737cd0f1440..57bc3efb7cd75 100644 --- a/crates/oxc_codegen/src/gen.rs +++ b/crates/oxc_codegen/src/gen.rs @@ -1807,9 +1807,7 @@ impl GenExpr for YieldExpression<'_> { p.print_soft_space(); } if let Some(argument) = self.argument.as_ref() { - if !self.delegate { - p.print_hard_space(); - } + p.print_soft_space(); argument.print_expr(p, Precedence::Yield, Context::empty()); } }); diff --git a/crates/oxc_codegen/tests/integration/unit.rs b/crates/oxc_codegen/tests/integration/unit.rs index a474a92a0dc39..a32add4cccb7c 100644 --- a/crates/oxc_codegen/tests/integration/unit.rs +++ b/crates/oxc_codegen/tests/integration/unit.rs @@ -164,14 +164,13 @@ fn r#yield() { test_minify("function *foo() { yield * async () => {} }", "function*foo(){yield*async()=>{}}"); test_minify("function *foo() { yield a ? b : c }", "function*foo(){yield a?b:c}"); test_minify("function *foo() { yield yield a }", "function*foo(){yield yield a}"); - test_minify("function *foo() { yield () => {} }", "function*foo(){yield ()=>{}}"); + test_minify("function *foo() { yield () => {} }", "function*foo(){yield()=>{}}"); test_minify("function *foo() { yield async () => {} }", "function*foo(){yield async()=>{}}"); test_minify( "function *foo() { yield { a } = [ b ] = c ? b : d }", - "function*foo(){yield {a}=[b]=c?b:d}", + "function*foo(){yield{a}=[b]=c?b:d}", ); - // TODO: remove the extra space in `yield (a,b)` - test_minify("function *foo() { yield (a, b) }", "function*foo(){yield (a,b)}"); + test_minify("function *foo() { yield (a, b) }", "function*foo(){yield(a,b)}"); test_minify("function *foo() { yield a, b }", "function*foo(){yield a,b}"); }