Skip to content

Commit 425b13b

Browse files
committed
fix: handle nested class fields
1 parent 30b38d0 commit 425b13b

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

crates/swc_ecma_transforms_compat/src/class_fields_use_set.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ impl VisitMut for ClassFieldsUseSet {
1515
noop_visit_mut_type!();
1616

1717
fn visit_mut_class(&mut self, n: &mut Class) {
18+
n.visit_mut_children_with(self);
19+
1820
let mut fields_handler = FieldsHandler::default();
1921
n.visit_mut_with(&mut fields_handler);
2022

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Foo {
2+
a = 1;
3+
#b = 2;
4+
static c = 3;
5+
static #d = 4;
6+
7+
foo() {
8+
class Bar {
9+
a = 1;
10+
#b = 2;
11+
static c = 3;
12+
static #d = 4;
13+
}
14+
}
15+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class Foo {
2+
#b;
3+
static{
4+
this.c = 3;
5+
}
6+
static #d = 4;
7+
foo() {
8+
class Bar {
9+
#b;
10+
static{
11+
this.c = 3;
12+
}
13+
static #d = 4;
14+
constructor(){
15+
this.a = 1;
16+
this.#b = 2;
17+
}
18+
}
19+
}
20+
constructor(){
21+
this.a = 1;
22+
this.#b = 2;
23+
}
24+
}

0 commit comments

Comments
 (0)