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

Fix handling of parenthesis with Flow's {Optional}IndexedAccess #11051

Merged
merged 1 commit into from
Jun 12, 2021

Conversation

gkz
Copy link
Contributor

@gkz gkz commented Jun 12, 2021

Description

Previously, we were not adding parens to the objectType of a IndexedAccess/OptionalIndexedAccess in the appropriate situations. Now we do.

E.g. previous output for

type A = (T & S)['bar'];
type B = (T | S)['bar'];
type C = (?T)['bar'];
type D = (typeof x)['bar'];
type E = (string => void)['bar'];

would be

type A = T & S["bar"];
type B = T | S["bar"];
type C = ?T["bar"];
type D = typeof x["bar"];
type E = (string) => void["bar"];

now it's

type A = (T & S)["bar"];
type B = (T | S)["bar"];
type C = (?T)["bar"];
type D = (typeof x)["bar"];
type E = ((string) => void)["bar"];

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@gkz gkz force-pushed the indexed-access-parens branch from 3d0c4c8 to 72499e5 Compare June 12, 2021 00:42
@gkz gkz force-pushed the indexed-access-parens branch from 72499e5 to 4e5a697 Compare June 12, 2021 00:51
@gkz gkz changed the title Fix handling of parenthesis with {Optional}IndexedAccess Fix handling of parenthesis with Flow's {Optional}IndexedAccess Jun 12, 2021
Copy link
Member

@fisker fisker left a comment

Choose a reason for hiding this comment

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

Thanks.

Copy link
Member

@sosukesuzuki sosukesuzuki left a comment

Choose a reason for hiding this comment

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

Thanks!

@sosukesuzuki sosukesuzuki merged commit 14188ae into prettier:main Jun 12, 2021
@gkz gkz deleted the indexed-access-parens branch June 13, 2021 23:36
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 14, 2022
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.

3 participants