diff --git a/crates/oxc_transformer/src/es2018/mod.rs b/crates/oxc_transformer/src/es2018/mod.rs index 6f12be237dcea..36265adce88dc 100644 --- a/crates/oxc_transformer/src/es2018/mod.rs +++ b/crates/oxc_transformer/src/es2018/mod.rs @@ -17,15 +17,16 @@ pub struct ES2018<'a> { options: ES2018Options, // Plugins - object_rest_spread: Option>, + object_rest_spread: ObjectRestSpread<'a>, } impl<'a> ES2018<'a> { pub fn new(options: ES2018Options, ctx: Ctx<'a>) -> Self { Self { - object_rest_spread: options - .object_rest_spread - .map(|options| ObjectRestSpread::new(options, Rc::clone(&ctx))), + object_rest_spread: ObjectRestSpread::new( + options.object_rest_spread.unwrap_or_default(), + Rc::clone(&ctx), + ), ctx, options, } @@ -34,8 +35,8 @@ impl<'a> ES2018<'a> { impl<'a> Traverse<'a> for ES2018<'a> { fn enter_expression(&mut self, expr: &mut Expression<'a>, ctx: &mut TraverseCtx<'a>) { - if let Some(object_rest_spread) = &mut self.object_rest_spread { - object_rest_spread.enter_expression(expr, ctx); + if self.options.object_rest_spread.is_some() { + self.object_rest_spread.enter_expression(expr, ctx); } } }