fix(es/helpers): Fix loose mode (#6691)

**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6581.
This commit is contained in:
Donny/강동윤 2022-12-20 19:11:12 +09:00 committed by GitHub
parent 923e4ff840
commit 5016ebed8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 1 deletions

View File

@ -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
}

View File

@ -0,0 +1,9 @@
class Hoge {
#hoge: number
constructor() {
this.#hoge = 42
}
}
new Hoge()
new Hoge()

View File

@ -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
}

View File

@ -0,0 +1,9 @@
class Hoge {
#hoge: number
constructor() {
this.#hoge = 42
}
}
new Hoge()
new Hoge()

View File

@ -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];
}