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

Bug: sort-type-union-intersection-members breaks code combining & and | #6158

Closed
4 tasks done
ysulyma opened this issue Dec 2, 2022 · 1 comment
Closed
4 tasks done
Labels
duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@ysulyma
Copy link

ysulyma commented Dec 2, 2022

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=4.9.3&sourceType=module&code=C4TwDgpgBAglC8UDeUCGAuKAiGWDcUAvgFCiRQBCCyUARplhfkaeNAMLUoDGD7zJVuQAi1ABScAPpQCUUAGSw8xIA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6ZAe2jqNNtiaUOTWs3yJoyRGXxCRAW0TyARhNQZIE6F0jgwAXxD6gA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

type A = { a: "A"; }
type B = { b: "B"; }
type C = { c: "C"; }

// this line violates @typescript-eslint/sort-type-union-intersection-members
export type D = (C | B) & A;

ESLint Config

{
  "extends": [
    "plugin:@typescript-eslint/recommended"
  ],
  "rules": {
    "@typescript-eslint/sort-type-union-intersection-members": "warn"
  }
}

tsconfig

{
  "compilerOptions": {
    // ...
  }
}

Expected Result

I expected that it would change the line to

export type D = A & (B | C);

Actual Result

It changed the line to

export type D = B | (A & C);

which has a different meaning from the original type.

Additional Info

No response

Versions

package version
@typescript-eslint/eslint-plugin 5.38.1
@typescript-eslint/parser 5.38.1
TypeScript 4.8.3
ESLint 8.24.0
node 16.17.0
@ysulyma ysulyma added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Dec 2, 2022
@bradzacher
Copy link
Member

This was fixed in #6118 and will be released with our next release.

@bradzacher bradzacher removed the triage Waiting for maintainers to take a look label Dec 3, 2022
@Josh-Cena Josh-Cena added duplicate This issue or pull request already exists and removed bug Something isn't working labels Dec 3, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 11, 2022
@JoshuaKGoldberg JoshuaKGoldberg closed this as not planned Won't fix, can't repro, duplicate, stale Aug 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

4 participants