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

prettier 2.8.2 adds superfluous parentheses to TSTypeOperator #14162

Closed
powercover opened this issue Jan 12, 2023 · 5 comments
Closed

prettier 2.8.2 adds superfluous parentheses to TSTypeOperator #14162

powercover opened this issue Jan 12, 2023 · 5 comments
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:intended Bug reports that actually turned out to be intended behavior

Comments

@powercover
Copy link

Environments:

  • Prettier Version: 2.8.2
  • Running Prettier via: CLI
  • Runtime: Node.js v19.2.0
  • Operating System: any

Input:
// prettier adds superfluous parentheses
// adding brackets around typeof something
type SomeType = typeof something[number];

Expected output:
type SomeType = typeof something[number];

Actual output:
type SomeType = (typeof something)[number];

@kachkaev
Copy link
Member

👋 @powercover! This change is intended, see #13546 and #14042

@kachkaev kachkaev added the type:intended Bug reports that actually turned out to be intended behavior label Jan 12, 2023
@viktomas
Copy link

I'm not sure if my opinion will be the majority opinion or not, but this change should IMO warrant a major version bump, not just a patch version. Upgrading prettier to 2.8.2 breaks builds that were green before.

@fisker
Copy link
Sponsor Member

fisker commented Jan 17, 2023

It's a regression in 1.19.

#13546 (comment)

@zomars
Copy link

zomars commented Jan 27, 2023

We're having this same issue. It introduces unexpected behavior. Also creates a massive war between prettier and eslint-config-prettier. The IDE displays an error while the CLI doesn't. At least an option to disable this would be nice.

image

EDIT:

Locking to 2.8.1 fixes it for now. As it trigger massive changes to our codebase. At least a major version warning would be nice.

@angelod1as
Copy link

Any way to disable this rule? I want to update the package in my project but this is resulting in wrong output.

const testObject = {
  first: 'a',
  second: ['first', 'second', 3]
}

typeof testObject.second[0]
// "string"

typeof testObject.second[2]
// "number"

(typeof testObject.second)[0]
// "o"

(typeof testObject.second)[2]
// "j" 

@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Nov 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:intended Bug reports that actually turned out to be intended behavior
Projects
None yet
Development

No branches or pull requests

6 participants