Skip to content

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

Merged
nicolo-ribaudo merged 5 commits intobabel:mainfrom
nicolo-ribaudo:this-computed-key-arrow
Nov 30, 2021
Merged

Fix handling of this&co in computed keys in arrows transform#14005
nicolo-ribaudo merged 5 commits intobabel:mainfrom
nicolo-ribaudo:this-computed-key-arrow

Conversation

@nicolo-ribaudo
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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?

Comment thread packages/babel-helper-environment-visitor/package.json

// TODO (Babel 8): Don't export this function.
export function skipAllButComputedKey(
path: NodePath<t.Method | t.ClassProperty | t.ClassPrivateProperty>,
Copy link
Copy Markdown
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 force-pushed the this-computed-key-arrow branch from 19b5871 to d27f33d Compare November 29, 2021 21:17
@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