forked from benjamn/recast
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parens: Emit parens where needed throughout Flow types; add tests
There were a couple of particular cases that were already covered, but many others that were not. I ran into one of them in practice (`A & (B | C)` was getting printed as `A & B | C`, which means something different) and looked into it, and decided to go about just fixing this whole class of issues. I started by scanning through all the different kinds of FlowType node, looking for any that could need parens around them; then I wrote up a comprehensive list of test cases. Once that was done, the whole thing turned out to be doable with a pretty reasonable amount of code! And given the tests, I'm hopeful that this logic is pretty much complete. Some of the added tests are skipped for now, because they involve function types and those currently have other bugs that cause those test cases to break. They start passing when this branch is merged with benjamn#1089, which fixes those other bugs.
- Loading branch information
Showing
2 changed files
with
182 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters