Skip to content

Commit

Permalink
fix: handle nested class fields
Browse files Browse the repository at this point in the history
  • Loading branch information
magic-akari committed Mar 10, 2023
1 parent 30b38d0 commit 425b13b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/swc_ecma_transforms_compat/src/class_fields_use_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ impl VisitMut for ClassFieldsUseSet {
noop_visit_mut_type!();

fn visit_mut_class(&mut self, n: &mut Class) {
n.visit_mut_children_with(self);

let mut fields_handler = FieldsHandler::default();
n.visit_mut_with(&mut fields_handler);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Foo {
a = 1;
#b = 2;
static c = 3;
static #d = 4;

foo() {
class Bar {
a = 1;
#b = 2;
static c = 3;
static #d = 4;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class Foo {
#b;
static{
this.c = 3;
}
static #d = 4;
foo() {
class Bar {
#b;
static{
this.c = 3;
}
static #d = 4;
constructor(){
this.a = 1;
this.#b = 2;
}
}
}
constructor(){
this.a = 1;
this.#b = 2;
}
}

0 comments on commit 425b13b

Please sign in to comment.