diff --git a/crates/oxc_transformer/src/es2022/class_properties.rs b/crates/oxc_transformer/src/es2022/class_properties.rs index 8a79ea02a580e4..0f88c84a802900 100644 --- a/crates/oxc_transformer/src/es2022/class_properties.rs +++ b/crates/oxc_transformer/src/es2022/class_properties.rs @@ -62,10 +62,10 @@ use serde::Deserialize; -use oxc_ast::{ast::*, AstBuilder, NONE}; +use oxc_ast::{ast::*, NONE}; use oxc_span::SPAN; use oxc_syntax::{node::NodeId, scope::ScopeFlags, symbol::SymbolFlags}; -use oxc_traverse::{Ancestor, Traverse, TraverseCtx}; +use oxc_traverse::{Ancestor, BoundIdentifier, Traverse, TraverseCtx}; use crate::{common::helper_loader::Helper, TransformCtx}; @@ -235,7 +235,7 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> { ); params_rest = Some(ctx.ast.alloc_binding_rest_element(SPAN, binding.create_binding_pattern(ctx))); - stmts.push(Self::create_super_call_stmt(binding.create_read_expression(ctx), ctx.ast)); + stmts.push(Self::create_super_call_stmt(&binding, ctx)); } // TODO: Should these have the span of the original `PropertyDefinition`s? stmts.extend(inits.into_iter().map(|expr| ctx.ast.statement_expression(SPAN, expr))); @@ -279,14 +279,18 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> { } /// `super(...args);` - fn create_super_call_stmt(args_ident: Expression<'a>, ast: AstBuilder<'a>) -> Statement<'a> { - ast.statement_expression( + fn create_super_call_stmt( + binding: &BoundIdentifier<'a>, + ctx: &mut TraverseCtx<'a>, + ) -> Statement<'a> { + let args_ident = binding.create_read_expression(ctx); + ctx.ast.statement_expression( SPAN, - ast.expression_call( + ctx.ast.expression_call( SPAN, - ast.expression_super(SPAN), + ctx.ast.expression_super(SPAN), NONE, - ast.vec1(ast.argument_spread_element(SPAN, args_ident)), + ctx.ast.vec1(ctx.ast.argument_spread_element(SPAN, args_ident)), false, ), )