New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Static method arrow function does not name anonymous function #7425
Comments
Hey @reggi! We really appreciate you taking the time to report an issue. The collaborators If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack |
Can you provide a repro? What are the plugins/presets you're using?
produces this output class M {
static green() {
return 'green';
}
}
Object.defineProperty(M, "blue", {
configurable: true,
enumerable: true,
writable: true,
value: () => 'green'
});
module.exports = M; and Babel & plugin version: |
@thymikee I guess he is using Also And it definitely could be polished, I'm not sure if function naming is centralized any where (this would mean that it's probably a bug) or is it scattered around the codebase and dependant on some helper usage (this would mean that we should detect the call site - where those functions are inserted and use helper on the inserted node) |
Oh, that's unfortunate. Looks like that arrow should be eventually replaced with a named function in both cases, right? |
Ain't sure if class properties (static or not) have inferred names - I think spec says they can, but I'm not the best ecma spec reader :/ |
I'm not an expert either, but looking at https://tc39.github.io/proposal-class-public-fields/#initialize-public-instance-fields I could tell the spec says |
Yeah, I suspect this is right reasoning. I guess the only way to 'fix' it is to transform directly to named functions, because at later point any other transform won't have enough info to infer the name correctly (just like in the |
Does this still need help? Can I pick this up? |
I'd expect
M.blue.name
to beblue
, but for some reason arrow functions don't have a name. Is this a bug or intentional?Guess I'd love it to be like this instead:
The text was updated successfully, but these errors were encountered: