You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class myclass {
#get(){
console.log("Hi from a method with a private identifier called #get");
}
constructor(){
this.#get();
}
}
const instance = new myclass();
🤔 Expected Behavior
The same (or identically behaving) output as good old 2.0.0-nightly.650+dc79abcd gives me:
! function() {
var t = 0;
function e(e) {
return "__private_" + t++ + "_" + e
}
var r = e("get");
function n() {
console.log("Hi from a method with a private identifier called #get")
}
new class {
constructor() {
Object.defineProperty(this, r, {
value: n
}), ((t, e) => {
if (!Object.prototype.hasOwnProperty.call(t, e)) throw new TypeError("attempted to use private field on non-instance");
return t
})(this, r)[r]()
}
}
}();
-> logs Hi from a method with a private identifier called #get to the console when ran
😯 Current Behavior
new class {
#get() {
console.log("Hi from a method with a private identifier called #get")
}
constructor() {
(function(t, e) {
if (!e.has(t)) throw new TypeError("attempted to get private field on non-instance");
return e.get(t).value
})(this, _get).call(this)
}
};
In firefox (which was my build target) -> Uncaught SyntaxError: private fields are not currently supported
In chrome: VM450:9 Uncaught ReferenceError: _get is not defined
💁 Possible Solution
Make it work correctly like it did before.
🔦 Context
I was, after already reporting multiple issues with the new SWC thing just by trying to use it and read the code, finally daring to run just a portion of the output code and it failed lol.
I think that swc does realize that Firefox 88 doesn't support them (because this.#get(); is indeed transpiled), and the declaration #get() { ... } is just not transpiled for some reason.
🐛 bug report
I was able to create simple input code which makes double wrong output!
parcel serve
andparcel build
if a class contains a private method called#get
.🎛 Configuration (.babelrc, package.json, cli command)
Please see attached .zip file
Sample code
🤔 Expected Behavior
The same (or identically behaving) output as good old
2.0.0-nightly.650+dc79abcd
gives me:-> logs
Hi from a method with a private identifier called #get
to the console when ran😯 Current Behavior
In firefox (which was my build target) ->
Uncaught SyntaxError: private fields are not currently supported
In chrome:
VM450:9 Uncaught ReferenceError: _get is not defined
💁 Possible Solution
Make it work correctly like it did before.
🔦 Context
I was, after already reporting multiple issues with the new SWC thing just by trying to use it and read the code, finally daring to run just a portion of the output code and it failed lol.
💻 Code Sample
parcel-hashtag-get.zip
🌍 Your Environment
The text was updated successfully, but these errors were encountered: