diff --git a/crates/swc/tests/exec/issues-6xxx/6581/1/.swcrc b/crates/swc/tests/exec/issues-6xxx/6581/1/.swcrc new file mode 100644 index 00000000000..f3fa9a79292 --- /dev/null +++ b/crates/swc/tests/exec/issues-6xxx/6581/1/.swcrc @@ -0,0 +1,19 @@ +{ + "jsc": { + "parser": { + "syntax": "typescript", + "tsx": true + }, + "target": "es2019", + "loose": true, + "minify": { + "compress": false, + "mangle": false + } + }, + "module": { + "type": "es6" + }, + "minify": false, + "isModule": true +} \ No newline at end of file diff --git a/crates/swc/tests/exec/issues-6xxx/6581/1/exec.ts b/crates/swc/tests/exec/issues-6xxx/6581/1/exec.ts new file mode 100644 index 00000000000..65f396e5efd --- /dev/null +++ b/crates/swc/tests/exec/issues-6xxx/6581/1/exec.ts @@ -0,0 +1,9 @@ +class Hoge { + #hoge: number + constructor() { + this.#hoge = 42 + } +} + +new Hoge() +new Hoge() \ No newline at end of file diff --git a/crates/swc/tests/exec/issues-6xxx/6581/2/.swcrc b/crates/swc/tests/exec/issues-6xxx/6581/2/.swcrc new file mode 100644 index 00000000000..4512d308541 --- /dev/null +++ b/crates/swc/tests/exec/issues-6xxx/6581/2/.swcrc @@ -0,0 +1,20 @@ +{ + "jsc": { + "parser": { + "syntax": "typescript", + "tsx": true + }, + "target": "es2019", + "loose": true, + "minify": { + "compress": false, + "mangle": false + }, + "externalHelpers": true + }, + "module": { + "type": "es6" + }, + "minify": false, + "isModule": true +} \ No newline at end of file diff --git a/crates/swc/tests/exec/issues-6xxx/6581/2/exec.ts b/crates/swc/tests/exec/issues-6xxx/6581/2/exec.ts new file mode 100644 index 00000000000..65f396e5efd --- /dev/null +++ b/crates/swc/tests/exec/issues-6xxx/6581/2/exec.ts @@ -0,0 +1,9 @@ +class Hoge { + #hoge: number + constructor() { + this.#hoge = 42 + } +} + +new Hoge() +new Hoge() \ No newline at end of file diff --git a/packages/swc-helpers/src/_class_private_field_loose_base.mjs b/packages/swc-helpers/src/_class_private_field_loose_base.mjs index c24fda439fb..79ca6c8ec3f 100644 --- a/packages/swc-helpers/src/_class_private_field_loose_base.mjs +++ b/packages/swc-helpers/src/_class_private_field_loose_base.mjs @@ -3,5 +3,5 @@ export default function _classPrivateFieldBase(receiver, privateKey) { throw new TypeError("attempted to use private field on non-instance"); } - return receiver; + return receiver[privateKey]; }