Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:added check for forXstatement pattern #11703
fix:added check for forXstatement pattern #11703
Changes from 2 commits
d4c0a5e
71f4c24
79f5619
a45c4dc
fff451b
d07e916
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a
path
is aForXStatement
, how can itsparentPath
be anAssignmentPattern
? Note that the children of anPattern
is always an expression. A statement can not be an expression.Here is an AST example of
for (o.p of arr);
The
parentPath
here refers to theNodePath
ofForOfStatement
.NodePath
is a wrapper of the AST node that providesparent
association with otherNodePath
. In this PR We would like to make sure thatmember
, which refers toMemberExpression
here, is indeed theleft
of the underlying AST node ofparentPath
.So we can use
The query function
isForXStatement
accepts an additional parameter as query, so the code above can be simplified asThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, when I run the test I seem to get the same results, which shouldn't happen?
input
output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output is expected. Can you add a test case from the original issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be reversed.
Please also add a test for for-in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a regression check on the first draft implementation: https://github.com/babel/babel/pull/11703/files/d4c0a5e8b75306f918cf2a2307e4f65130f9ea05#diff-decaf745088978f783d453709a8a8479
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooo, ok. So we need 2 new test cases (for-of and for-in) with it appearing in the
left
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 can just do it in the next line, or leave a comment that it shouldn't be transformed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
personally I think just doing them all in the same class is fine
the empty arr seems to be the same case?
and I would rename
1-helpermemberexpressionfunction
to something like for-of-member-expression or somethingThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for sure, will remember for next time!