Skip to content
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

Fix handling of this&co in computed keys in arrows transform #14005

Merged
merged 5 commits into from Nov 30, 2021

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Nov 28, 2021

Q                       A
Fixed Issues? Fixes #13981
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

I had to extract environmentVisitor to a new package to avoid circular deps between @babel/traverse and @babell/helper-replace-supers.

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: traverse labels Nov 28, 2021
@nicolo-ribaudo nicolo-ribaudo changed the title This computed key arrow Fix handling of this&co in computed keys in arrows transform Nov 28, 2021
@babel-bot
Copy link
Collaborator

babel-bot commented Nov 28, 2021

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/50027/

Comment on lines 34 to 40
Function(path: NodePath<t.Function>) {
// Methods will be handled by the Method visit
if (path.isMethod()) return;
// Arrow functions inherit their parent's environment
if (path.isArrowFunctionExpression()) return;
path.skip();
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove it and add FunctionDeclaration and FunctionExpression to skipKey?


// TODO (Babel 8): Don't export this function.
export function skipAllButComputedKey(
path: NodePath<t.Method | t.ClassProperty | t.ClassPrivateProperty>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that skipAllButComputedKey is not invoked on ClassPrivateProperty.

@nicolo-ribaudo nicolo-ribaudo merged commit 36a5ac4 into babel:main Nov 30, 2021
@nicolo-ribaudo nicolo-ribaudo deleted the this-computed-key-arrow branch November 30, 2021 21:54
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Mar 2, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: traverse PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Incorrectly transpile this in object getter/setter/method in arrow function
4 participants