diff --git a/crates/oxc_ast/src/ast_builder.rs b/crates/oxc_ast/src/ast_builder.rs index 7483b806a..eda5b029b 100644 --- a/crates/oxc_ast/src/ast_builder.rs +++ b/crates/oxc_ast/src/ast_builder.rs @@ -402,7 +402,7 @@ impl<'a> AstBuilder<'a> { Expression::ArrayExpression(self.alloc(ArrayExpression { span, elements, trailing_comma })) } - pub fn arrow_expression( + pub fn arrow_function_expression( &self, span: Span, expression: bool, diff --git a/crates/oxc_parser/src/js/function.rs b/crates/oxc_parser/src/js/function.rs index deb7f38bb..737b34cea 100644 --- a/crates/oxc_parser/src/js/function.rs +++ b/crates/oxc_parser/src/js/function.rs @@ -250,7 +250,7 @@ impl<'a> ParserImpl<'a> { }; self.ctx = self.ctx.and_await(has_await).and_yield(has_yield); - Ok(self.ast.arrow_expression( + Ok(self.ast.arrow_function_expression( self.end_span(span), expression, r#async, @@ -515,7 +515,7 @@ impl<'a> ParserImpl<'a> { self.ctx = self.ctx.and_await(has_await).and_yield(has_yield); - Ok(self.ast.arrow_expression( + Ok(self.ast.arrow_function_expression( self.end_span(span), expression, r#async, diff --git a/crates/oxc_transformer/src/es2022/class_static_block.rs b/crates/oxc_transformer/src/es2022/class_static_block.rs index af53b062c..498e9f4a2 100644 --- a/crates/oxc_transformer/src/es2022/class_static_block.rs +++ b/crates/oxc_transformer/src/es2022/class_static_block.rs @@ -84,7 +84,7 @@ impl<'a> ClassStaticBlock<'a> { let function_body = self.ast.function_body(SPAN, self.ast.new_vec(), statements); - let callee = self.ast.arrow_expression( + let callee = self.ast.arrow_function_expression( SPAN, false, false, diff --git a/crates/oxc_transformer/src/proposals/decorators.rs b/crates/oxc_transformer/src/proposals/decorators.rs index ad37ec767..6ac533bfd 100644 --- a/crates/oxc_transformer/src/proposals/decorators.rs +++ b/crates/oxc_transformer/src/proposals/decorators.rs @@ -452,48 +452,59 @@ impl<'a> Decorators<'a> { { if flag.is_setter() && !flag.is_static() { // _ => #a in _; - private_in_expressions.push(self.ast.arrow_expression( - SPAN, - true, - false, - self.ast.formal_parameters( + private_in_expressions.push( + self.ast.arrow_function_expression( SPAN, - FormalParameterKind::ArrowFormalParameters, - self.ast.new_vec_single(self.ast.formal_parameter( + true, + false, + self.ast.formal_parameters( SPAN, - self.ast.binding_pattern( - self.ast.binding_pattern_identifier( - BindingIdentifier::new(SPAN, "_".into()), + FormalParameterKind::ArrowFormalParameters, + self.ast.new_vec_single(self.ast.formal_parameter( + SPAN, + self.ast.binding_pattern( + self.ast.binding_pattern_identifier( + BindingIdentifier::new( + SPAN, + "_".into(), + ), + ), + None, + false, ), None, false, - ), + self.ast.new_vec(), + )), None, - false, + ), + self.ast.function_body( + SPAN, self.ast.new_vec(), - )), + self.ast.new_vec_single( + self.ast.expression_statement( + SPAN, + self.ast.private_in_expression( + SPAN, + PrivateIdentifier::new( + SPAN, + def.key.private_name().unwrap(), + ), + self.ast + .identifier_reference_expression( + IdentifierReference::new( + SPAN, + "_".into(), + ), + ), + ), + ), + ), + ), + None, None, ), - self.ast.function_body( - SPAN, - self.ast.new_vec(), - self.ast.new_vec_single(self.ast.expression_statement( - SPAN, - self.ast.private_in_expression( - SPAN, - PrivateIdentifier::new( - SPAN, - def.key.private_name().unwrap(), - ), - self.ast.identifier_reference_expression( - IdentifierReference::new(SPAN, "_".into()), - ), - ), - )), - ), - None, - None, - )); + ); } } @@ -906,7 +917,7 @@ impl<'a> Decorators<'a> { None, ); decorator_elements.push(ArrayExpressionElement::Expression( - self.ast.arrow_expression( + self.ast.arrow_function_expression( SPAN, true, false, @@ -949,7 +960,7 @@ impl<'a> Decorators<'a> { ); decorator_elements.push(ArrayExpressionElement::Expression( - self.ast.arrow_expression( + self.ast.arrow_function_expression( SPAN, true, false, diff --git a/crates/oxc_transformer/src/typescript/mod.rs b/crates/oxc_transformer/src/typescript/mod.rs index 85d40f5ee..f57280e86 100644 --- a/crates/oxc_transformer/src/typescript/mod.rs +++ b/crates/oxc_transformer/src/typescript/mod.rs @@ -535,7 +535,8 @@ impl<'a> TypeScript<'a> { let statements = self.transform_ts_enum_members(&mut decl.body.members, &enum_name); let body = self.ast.function_body(decl.body.span, self.ast.new_vec(), statements); - let callee = self.ast.arrow_expression(SPAN, false, false, params, body, None, None); + let callee = + self.ast.arrow_function_expression(SPAN, false, false, params, body, None, None); // })(Foo || {}); let mut arguments = self.ast.new_vec();