Skip to content

Flow enums: fix enum body location#10737

Merged
existentialism merged 2 commits intobabel:masterfrom
gkz:flow-enums-locs-fix
Nov 20, 2019
Merged

Flow enums: fix enum body location#10737
existentialism merged 2 commits intobabel:masterfrom
gkz:flow-enums-locs-fix

Conversation

@gkz
Copy link
Copy Markdown
Contributor

@gkz gkz commented Nov 19, 2019

The location of the Flow enum bodys was incorrect. I fixed this in flow-parser (facebook/flow@498a209), and this PR fixes this in Babel, making it consistent with flow-parser, and also consistent with what the enum body contains (everything after enum E).

The diff also does some minor refactoring and cleaning up:

  • Splits out parsing of the enum body into a separate function (separate from parsing the enum declaration overall)
  • Rather than have a helper function for enum string bodies, it returns the string members, so the creation of enum bodies is completely contained in the new flowEnumBody function.

This incorrect location was discovering when adding support in Prettier prettier/prettier#6860

After this lands and they update their parser deps, Prettier can remove their hacks.

Q                       A
Fixed Issues?
Patch: Bug Fix? 👍
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

@nicolo-ribaudo nicolo-ribaudo added area: flow pkg: parser PR: Bug Fix 🐛 A type of pull request used for our changelog categories labels Nov 19, 2019
@nicolo-ribaudo
Copy link
Copy Markdown
Member

(Please run yarn install && make fix)

Copy link
Copy Markdown
Member

@existentialism existentialism left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 (baring lint fix)

@existentialism existentialism merged commit 01d6d6d into babel:master Nov 20, 2019
@existentialism
Copy link
Copy Markdown
Member

@gkz thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: flow outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser PR: Bug Fix 🐛 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants