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: object-shorthand loses type parameters when auto-fixing #9008

Closed
4 tasks done
aldeed opened this issue Apr 26, 2024 · 3 comments
Closed
4 tasks done

Bug: object-shorthand loses type parameters when auto-fixing #9008

aldeed opened this issue Apr 26, 2024 · 3 comments
Labels
bug Something isn't working external This issue is with another package, not typescript-eslint itself package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin wontfix This will not be worked on

Comments

@aldeed
Copy link

aldeed commented Apr 26, 2024

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=5.4.5&fileType=.ts&code=MYewdgzgLgBFCm0DyAjAVjAvDA3gKBhgFsBPAWXigAsQATALhgB4AVAPgAoR1GWBKXlja4ChGACdKAV3FgY3NAG5RAXwA0eFcqA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQPYCMArRAYwBcBaZAC12jOoEMA7AE3TAG1xsdFpodSABoevSI3gB3RgE9Uo3hCxKcjAG64AlqwCiADwAO8LSS1kASojKxozAIIDcU1BjJxEY7AF8vAXR5fbyA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

const testObj = {
  myMethod: <T>(obj: T): T => {
    return obj;
  },
};

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "object-shorthand": [
      "error",
      "always",
      { avoidExplicitReturnArrows: true },
    ],
  },
};

tsconfig

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

Expected Result

The correct fixed code is:

const testObj = {
  myMethod<T>(obj: T): T {
    return obj;
  },
};

Actual Result

const testObj = {
  myMethod(obj: T): T {
    return obj;
  },
};

(<T> parameter is missing)

Additional Info

No response

@aldeed aldeed 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 Apr 26, 2024
@kirkwaiblinger kirkwaiblinger added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for maintainers to take a look labels Apr 26, 2024
@kirkwaiblinger
Copy link
Member

@aldeed Yep! Thanks for the report!

@kirkwaiblinger kirkwaiblinger added triage Waiting for maintainers to take a look and removed accepting prs Go ahead, send a pull request that resolves this issue labels Apr 26, 2024
@kirkwaiblinger
Copy link
Member

@aldeed Yep! Thanks for the report!

Whoops! I spoke too soon. object-shorthand isn't actually a typescript-eslint rule (or corresponding extension rule), so this would be an issue to try to take up with eslint core first

@kirkwaiblinger
Copy link
Member

Mentioning this issue may help you in making a report to eslint core: eslint/eslint#12260 🙂

@kirkwaiblinger kirkwaiblinger added the external This issue is with another package, not typescript-eslint itself label Apr 26, 2024
@kirkwaiblinger kirkwaiblinger closed this as not planned Won't fix, can't repro, duplicate, stale May 7, 2024
@auvred auvred added wontfix This will not be worked on and removed triage Waiting for maintainers to take a look labels May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working external This issue is with another package, not typescript-eslint itself package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants