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 classNameTDZError in computed prototype methods with class fields #11068

Merged
merged 7 commits into from Feb 12, 2020

Conversation

sidntrivedi012
Copy link
Contributor

@sidntrivedi012 sidntrivedi012 commented Jan 29, 2020

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

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories Spec: Class Fields labels Jan 29, 2020
@sidntrivedi012
Copy link
Contributor Author

@nicolo-ribaudo Have extracted the method handleClassTDZ from classFieldDefinitionEvaluationTDZVisitor.

But, this.classBinding throws error : Cannot read classBinding of undefined.

@nicolo-ribaudo
Copy link
Member

Instead of this, you can try to use the second parameter

@sidntrivedi012
Copy link
Contributor Author

sidntrivedi012 commented Jan 29, 2020

Done. PTAL.

Also, all the tests are passing now.
Screenshot 2020-01-30 at 5 30 05 AM

@sidntrivedi012 sidntrivedi012 changed the title [Draft] Fix classNameTDZError in computed prototype methods with class fields Fix classNameTDZError in computed prototype methods with class fields Jan 30, 2020
classBinding: path.node.id && path.scope.getBinding(path.node.id.name),
file,
});
if (computedPath.get("key").isReferencedIdentifier()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we cache computedPath.get("key")? It is also used in !computedPath.get("key").isConstantExpression() later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JLHwung Done. PTAL 🙂

@nicolo-ribaudo nicolo-ribaudo merged commit 3fc904e into babel:master Feb 12, 2020
rajasekarm pushed a commit to rajasekarm/babel that referenced this pull request Feb 17, 2020
…babel#11068)

* Draft fix for TDZError in computed prototype methods

* Added tests for loose:false and also extracted handleClassTDZ

* Added state parameter to handleClassTDZ function

* Extracted the state object to a variable

* Added helper comments for environmentVisitor

* Added else condition to traverse computed Path

* Cached computed path key into a variable
@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 May 14, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2020
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 PR: Bug Fix 🐛 A type of pull request used for our changelog categories Spec: Class Fields
Projects
None yet
Development

Successfully merging this pull request may close these issues.

classNameTDZError in computed prototype methods with class fields
3 participants