Bug Report
Current Behavior
When a function is assigned to a private field, its name property should (I think) be name of the private field. Instead, the name is always value.
Input Code
class A {
#foo = function () {};
constructor () {
console.log(this.#foo.name);
}
}
new A(); // should log something else (see below)
Expected behavior/code
The code above should log 'foo'.
The code above should log '#foo'
see comment below, I think I read the spec wrong before
Babel Configuration (.babelrc, package.json, cli command)
repl link
Possible Solution
The function generated WeakMap entry could use the name of the private field ('foo' in this case instead of 'value'). per the spec proposal
_foo.set(this, {
writable: true,
value: function value() {}
});
Side note: not sure what the 'writable' part is doing: what's a read-only private field?
Additional context/Screenshots
Bug Report
Current Behavior
When a function is assigned to a private field, its
nameproperty should (I think) be name of the private field. Instead, the name is alwaysvalue.Input Code
Expected behavior/code
The code above should log 'foo'.The code above should log '#foo'
Babel Configuration (.babelrc, package.json, cli command)
repl link
Possible Solution
The function generated WeakMap entry could use the name of the private field ('foo' in this case instead of 'value'). per the spec proposal
Additional context/Screenshots