Skip to content
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

Closed
wants to merge 8 commits into from
Closed

Fix flow plugin when flow+arrow+spread used together #6

wants to merge 8 commits into from

Conversation

danez
Copy link
Member

@danez danez commented Mar 12, 2016

Fix for

( ...props: SomeType ) : ?ReturnType => ( 3 );

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 otherwise undefined.
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 in parseParenItem
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 specific
this.expect(tt.parenL) inside parseParenAndDistinguishExpression.

And I reverted the fix from babel/babel#3305 as it is not necessary anymore.

Fixes babel/T2612

sebmck and others added 8 commits March 10, 2016 06:24
don't ignore compiled files
Merge branch 'master' of github.com:babel/babylon
The fix includes creating 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` otherwise `undefined`.
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 in `parseParenItem`
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 is correct as it is now inline with parsing without flow annotation. No extra
is added for arrow function without type annotations.

In the expression-parser `this.next()` was replaced by a more specific
`this.expect(tt.parenL)`.
@loganfsmyth
Copy link
Member

This was auto-closed because this repo has been updated to include the Git history from the main Babel repo. I can't speak to the validity of this PR, but it appears you'll need to rebase and open a new one.

The new force-pused master branch should be identical to the old one, so you should be able to use rebase --onto or cherry-pick to move your commit over.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants