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

Flow cannot parse conditional expression that includes assignment and arrow #8731

Open
sosukesuzuki opened this issue Aug 18, 2021 · 1 comment

Comments

@sosukesuzuki
Copy link

Flow version: 0.157.0

Expected behavior

Succeeds in parsing the following code

(a ? (b = c) : d => e);

Actual behavior

Failed to parse the above code

Additional Info

@babel/parser can parse the above code since 7.15.3 (ref: babel/babel#13655 )

@SamChou19815
Copy link
Contributor

I think Flow is interpreting the sequence (b = c) : d => e to be an arrow function with parameter b of default value c, with return type d and return value e.
It considers the entire sequence as the first branch of the ternary expression, so it expects a : to start the second branch.
Actually TypeScript seems to have the same problem.

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

No branches or pull requests

3 participants