Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(es/compat): Don't modify private fields from reserved_words pass #7113

Merged
merged 13 commits into from Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions crates/swc/tests/fixture/issues-7xxx/7106/input/.swcrc
@@ -0,0 +1,19 @@
{
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": false
},
"target": "es2022",
"loose": false,
"minify": {
"compress": false,
"mangle": false
}
},
"module": {
"type": "es6"
},
"minify": false,
"isModule": true
}
8 changes: 8 additions & 0 deletions crates/swc/tests/fixture/issues-7xxx/7106/input/input.js
@@ -0,0 +1,8 @@
export class test {
#throw() { };
#new() { };
test() {
this.#throw();
this.#new();
}
}
8 changes: 8 additions & 0 deletions crates/swc/tests/fixture/issues-7xxx/7106/output/input.js
@@ -0,0 +1,8 @@
export class test {
#throw() {}
#new() {}
test() {
this.#throw();
this.#new();
}
}
2 changes: 2 additions & 0 deletions crates/swc_ecma_transforms_compat/src/reserved_words.rs
Expand Up @@ -35,6 +35,8 @@ impl VisitMut for EsReservedWord {
s.local.visit_mut_with(self);
}

fn visit_mut_private_name(&mut self, _: &mut PrivateName) {}

fn visit_mut_prop_name(&mut self, _n: &mut PropName) {}
}

Expand Down
@@ -0,0 +1,8 @@
export class test {
#throw() { }
#new() { }
test() {
this.#throw();
this.#new();
}
}
@@ -0,0 +1,8 @@
export class test {
#throw() {}
#new() {}
test() {
this.#throw();
this.#new();
}
}
26 changes: 26 additions & 0 deletions crates/swc_ecma_transforms_typescript/tests/strip.rs
Expand Up @@ -4532,3 +4532,29 @@ test!(
A[A["a"] = a] = "a";
})(A || (A = {}))"#
);

test!(
::swc_ecma_parser::Syntax::Typescript(Default::default()),
|_| tr(),
issue_7106,
"
export class test {
#throw() {}
#new() {}
test() {
this.#throw();
this.#new();
}
}
",
"
export class test {
#throw() {}
#new() {}
test() {
this.#throw();
this.#new();
}
}
"
);