Improve getBindingIdentifiers#16544
Conversation
395f202 to
b19e582
Compare
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/57109 |
| !path.get("id").node[NOT_LOCAL_BINDING] | ||
| ) { | ||
| path.scope.registerBinding("local", path); | ||
| path.scope.registerBinding("local", path.get("id"), path); |
There was a problem hiding this comment.
Since the changes in @babel/types will break old versions of @babel/traverse, here we defer the ClassExpression change to Babel 8. On the other hand, the UpdateExpression change does not break other packages, so we could ship it in Babel 7.
7fbab12 to
6852dc3
Compare
| // TODO(@nicolo-ribaudo): Check if we can remove them from .keys in a | ||
| // backward-compatible way, and if not what we need to do to remove them | ||
| // in Babel 8. |
There was a problem hiding this comment.
Even if you are not me, would you like to do this? :)
There was a problem hiding this comment.
Our scope tracker would register constant violations based on the information here. I think we need a utility such as getAssignmentIdentifiers for the assignment pattern as getBindingIdentifiers for the binding pattern, which we already have. They will definitely share the destructuring AST access but getAssignmentIdentifiers will also handle assignments, update and delete expressions as well.
Because it will be a small feature either for @babel/types or for @babel/traverse, I suggest we open a separate PR for that.
getOuterBindingIdentifiersshould not return the class id for class expressionsWhen
newBindingOnlyistrue,getBindingIdentifierswill not consider anUpdateExpressionas a binding path.More tests are also provided.