This repository has been archived by the owner on May 19, 2018. It is now read-only.
Fix flow plugin when flow+arrow+spread used together #6
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.
Fix for
The fix creates a new method on the parser called
parseArrow
.This new function by default only checks if current position matches an
arrow. If it does returns the
node
otherwiseundefined
.The flow plugin can then extend this function and correctly parse the typeAnnotation
and add it to the node.
With this change, in the flow plugin there is no need anymore to extend
parseParenAndDistinguishExpression
and the arrow handling inparseParenItem
could also be removed, because it is all handled now in
parseArrow
.Some existing tests were failing, because
extra->parentesized
is now missing,but this should be correct as it is now inline with the parsing without flow annotations. No
extra
is added for arrow function without type annotations.
Also, in the expression-parser
this.next()
was replaced by a more specificthis.expect(tt.parenL)
insideparseParenAndDistinguishExpression
.And I reverted the fix from babel/babel#3305 as it is not necessary anymore.
Fixes babel/T2612