@@ -477,7 +477,7 @@ impl Gen for ReturnStatement<'_> {
477477 p. print_space_before_identifier ( ) ;
478478 p. print_str ( "return" ) ;
479479 if let Some ( arg) = & self . argument {
480- p. print_hard_space ( ) ;
480+ p. print_soft_space ( ) ;
481481 p. print_expression ( arg) ;
482482 }
483483 p. print_semicolon_after_statement ( ) ;
@@ -531,7 +531,8 @@ impl Gen for ThrowStatement<'_> {
531531 fn gen ( & self , p : & mut Codegen , _ctx : Context ) {
532532 p. add_source_mapping ( self . span ) ;
533533 p. print_indent ( ) ;
534- p. print_str ( "throw " ) ;
534+ p. print_str ( "throw" ) ;
535+ p. print_soft_space ( ) ;
535536 p. print_expression ( & self . argument ) ;
536537 p. print_semicolon_after_statement ( ) ;
537538 }
@@ -1316,8 +1317,8 @@ impl Gen for StringLiteral<'_> {
13161317
13171318impl Gen for ThisExpression {
13181319 fn gen ( & self , p : & mut Codegen , _ctx : Context ) {
1319- p. add_source_mapping ( self . span ) ;
13201320 p. print_space_before_identifier ( ) ;
1321+ p. add_source_mapping ( self . span ) ;
13211322 p. print_str ( "this" ) ;
13221323 }
13231324}
@@ -1628,14 +1629,11 @@ impl GenExpr for ArrowFunctionExpression<'_> {
16281629 p. wrap ( precedence >= Precedence :: Assign , |p| {
16291630 p. print_annotation_comments ( self . span . start ) ;
16301631 if self . r#async {
1632+ p. print_space_before_identifier ( ) ;
16311633 p. add_source_mapping ( self . span ) ;
16321634 p. print_str ( "async" ) ;
1635+ p. print_soft_space ( ) ;
16331636 }
1634-
1635- if self . r#async {
1636- p. print_hard_space ( ) ;
1637- }
1638-
16391637 if let Some ( type_parameters) = & self . type_parameters {
16401638 type_parameters. print ( p, ctx) ;
16411639 }
@@ -1666,8 +1664,8 @@ impl GenExpr for ArrowFunctionExpression<'_> {
16661664impl GenExpr for YieldExpression < ' _ > {
16671665 fn gen_expr ( & self , p : & mut Codegen , precedence : Precedence , _ctx : Context ) {
16681666 p. wrap ( precedence >= Precedence :: Assign , |p| {
1669- p. add_source_mapping ( self . span ) ;
16701667 p. print_space_before_identifier ( ) ;
1668+ p. add_source_mapping ( self . span ) ;
16711669 p. print_str ( "yield" ) ;
16721670 if self . delegate {
16731671 p. print_ascii_byte ( b'*' ) ;
@@ -1992,6 +1990,7 @@ impl GenExpr for ImportExpression<'_> {
19921990 || self . arguments . first ( ) . is_some_and ( |argument| p. has_comment ( argument. span ( ) . start ) ) ;
19931991
19941992 p. wrap ( wrap, |p| {
1993+ p. print_space_before_identifier ( ) ;
19951994 p. add_source_mapping ( self . span ) ;
19961995 p. print_str ( "import(" ) ;
19971996 if has_comment {
@@ -2059,6 +2058,7 @@ impl Gen for TaggedTemplateExpression<'_> {
20592058
20602059impl Gen for Super {
20612060 fn gen ( & self , p : & mut Codegen , _ctx : Context ) {
2061+ p. print_space_before_identifier ( ) ;
20622062 p. add_source_mapping ( self . span ) ;
20632063 p. print_str ( "super" ) ;
20642064 }
@@ -2067,8 +2067,10 @@ impl Gen for Super {
20672067impl GenExpr for AwaitExpression < ' _ > {
20682068 fn gen_expr ( & self , p : & mut Codegen , precedence : Precedence , ctx : Context ) {
20692069 p. wrap ( precedence >= self . precedence ( ) , |p| {
2070+ p. print_space_before_identifier ( ) ;
20702071 p. add_source_mapping ( self . span ) ;
2071- p. print_str ( "await " ) ;
2072+ p. print_str ( "await" ) ;
2073+ p. print_soft_space ( ) ;
20722074 self . argument . print_expr ( p, Precedence :: Exponentiation , ctx) ;
20732075 } ) ;
20742076 }
@@ -2181,6 +2183,7 @@ impl GenExpr for TSTypeAssertion<'_> {
21812183
21822184impl Gen for MetaProperty < ' _ > {
21832185 fn gen ( & self , p : & mut Codegen , ctx : Context ) {
2186+ p. print_space_before_identifier ( ) ;
21842187 p. add_source_mapping ( self . span ) ;
21852188 self . meta . print ( p, ctx) ;
21862189 p. print_ascii_byte ( b'.' ) ;
@@ -2198,6 +2201,8 @@ impl Gen for Class<'_> {
21982201 decorator. print ( p, ctx) ;
21992202 p. print_hard_space ( ) ;
22002203 }
2204+ p. print_space_before_identifier ( ) ;
2205+ p. add_source_mapping ( self . span ) ;
22012206 if self . declare {
22022207 p. print_str ( "declare " ) ;
22032208 }
0 commit comments