diff --git a/crates/swc/tests/fixture/issues-7xxx/7106/input/.swcrc b/crates/swc/tests/fixture/issues-7xxx/7106/input/.swcrc new file mode 100644 index 000000000000..3dc717ffb5e7 --- /dev/null +++ b/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 +} \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-7xxx/7106/input/input.js b/crates/swc/tests/fixture/issues-7xxx/7106/input/input.js new file mode 100644 index 000000000000..56815c468648 --- /dev/null +++ b/crates/swc/tests/fixture/issues-7xxx/7106/input/input.js @@ -0,0 +1,8 @@ +export class test { + #throw() { }; + #new() { }; + test() { + this.#throw(); + this.#new(); + } +} \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-7xxx/7106/output/input.js b/crates/swc/tests/fixture/issues-7xxx/7106/output/input.js new file mode 100644 index 000000000000..99856e60fb22 --- /dev/null +++ b/crates/swc/tests/fixture/issues-7xxx/7106/output/input.js @@ -0,0 +1,8 @@ +export class test { + #throw() {} + #new() {} + test() { + this.#throw(); + this.#new(); + } +} diff --git a/crates/swc_ecma_transforms_compat/src/reserved_words.rs b/crates/swc_ecma_transforms_compat/src/reserved_words.rs index 3b4e7717265f..49af049cee54 100644 --- a/crates/swc_ecma_transforms_compat/src/reserved_words.rs +++ b/crates/swc_ecma_transforms_compat/src/reserved_words.rs @@ -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) {} } diff --git a/crates/swc_ecma_transforms_compat/tests/static-blocks/issue-7106/input.js b/crates/swc_ecma_transforms_compat/tests/static-blocks/issue-7106/input.js new file mode 100644 index 000000000000..557577f5dd5e --- /dev/null +++ b/crates/swc_ecma_transforms_compat/tests/static-blocks/issue-7106/input.js @@ -0,0 +1,8 @@ +export class test { + #throw() { } + #new() { } + test() { + this.#throw(); + this.#new(); + } +} diff --git a/crates/swc_ecma_transforms_compat/tests/static-blocks/issue-7106/output.js b/crates/swc_ecma_transforms_compat/tests/static-blocks/issue-7106/output.js new file mode 100644 index 000000000000..99856e60fb22 --- /dev/null +++ b/crates/swc_ecma_transforms_compat/tests/static-blocks/issue-7106/output.js @@ -0,0 +1,8 @@ +export class test { + #throw() {} + #new() {} + test() { + this.#throw(); + this.#new(); + } +} diff --git a/crates/swc_ecma_transforms_typescript/tests/strip.rs b/crates/swc_ecma_transforms_typescript/tests/strip.rs index 5d22a3ef7eed..9dcbc1facbe9 100644 --- a/crates/swc_ecma_transforms_typescript/tests/strip.rs +++ b/crates/swc_ecma_transforms_typescript/tests/strip.rs @@ -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(); + } + } + " +);