Skip to content

Commit

Permalink
fix(es/compat): Set inserted var inside export class in destructing (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Austaras authored Jan 2, 2024
1 parent ae65961 commit 4416077
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
18 changes: 18 additions & 0 deletions crates/swc_ecma_compat_es2015/src/destructuring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,24 @@ impl VisitMut for AssignFolder {
self.exporting = exporting;
}

fn visit_mut_class(&mut self, f: &mut Class) {
let exporting = mem::replace(&mut self.exporting, false);
f.visit_mut_children_with(self);
self.exporting = exporting;
}

fn visit_mut_object_lit(&mut self, f: &mut ObjectLit) {
let exporting = mem::replace(&mut self.exporting, false);
f.visit_mut_children_with(self);
self.exporting = exporting;
}

fn visit_mut_arrow_expr(&mut self, f: &mut ArrowExpr) {
let exporting = mem::replace(&mut self.exporting, false);
f.visit_mut_children_with(self);
self.exporting = exporting;
}

fn visit_mut_expr(&mut self, expr: &mut Expr) {
let ignore_return_value = self.ignore_return_value.take().is_some();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export class A {
constructor(t, { a, b = 6, c } = {}) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class A {
constructor(t, ref){
let _ref = ref === void 0 ? {} : ref, a = _ref.a, _ref_b = _ref.b, b = _ref_b === void 0 ? 6 : _ref_b, c = _ref.c;
}
}

0 comments on commit 4416077

Please sign in to comment.