Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Feature: [unified-signatures] Option to not report when signature has different JSDoc #10520

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

Closed
4 tasks done
nicolo-ribaudo opened this issue Dec 19, 2024 · 5 comments Β· Fixed by #10781
Closed
4 tasks done
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement New feature or request locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@nicolo-ribaudo
Copy link

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&showAST=es&fileType=.tsx&code=FAEwpgxgNghgTmABAMwK4DsIBcCWB7dFACgA8AuRdVAWwCMw4BKCjAa3TwHd0BuYAegBUgxAAFwABwQQYWMCESD%2BicNHhI0mXAWLlEtPHihgY6ZojYdufYMiIBGRnztY4qME%2BBA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6WJygM0sQBNaySgHMmAQ3yxoKdGACM4MAF8QSoA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

declare function f(x: number): unknown;
/** @deprecated */ declare function f(x: boolean): unknown;

f(1);
f(true);

ESLint Config

{
  "rules": {
    "@typescript-eslint/unified-signatures": 1
  }
}

tsconfig

No response

Expected Result

It should not warn, because the two signatures cannot be unified. Note that the call f(true) is striked as "deprecated", and it would not be possible for it to happen if the two function declarations were merged into a single one.

Actual Result

It reports

These overloads can be combined into one signature taking number | boolean.

Additional Info

No response

@nicolo-ribaudo nicolo-ribaudo added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Dec 19, 2024
@kirkwaiblinger
Copy link
Member

Hi @nicolo-ribaudo !

I can see the argument, but I'm not sure it will make sense for us to support this. We generally don't touch JSDocs. The sort-of exception to this is no-deprecated, which works via TS's type information, rather than us interacting with JSDocs directly, but that isn't available to us here, since unified-signatures isn't type-aware.

My intuition is to think of this as a bandwidth/scope limitation that is best solved with an eslint-disable comment. Curious for thoughts from @typescript-eslint/triage-team.

@JoshuaKGoldberg
Copy link
Member

Blurgh. If unified-signatures was type-aware I think this would be easily something to accept, no complications.

But, since the JSDocs are all in-place, maybe we can fake it? Just go purely off syntax by getting and parsing the JSDoc comments for the nodes themselves? Performance shouldn't be impacted significantly given that it's only one node per overload.

@kirkwaiblinger
Copy link
Member

If we entertain this, then I'd ask whether we should generally consider signatures that have different JSDocs πŸ€”....

Playground

/**
 * This signature does something.
 */
declare function f(x: number): void;

/**
 * This signature does something else.
 */
declare function f(x: string): void;

@bradzacher
Copy link
Member

Yeah I don't think we really want to go into the realm of "partially supporting specific cases of JSDoc and ignoring all other comment contents" cos it does create an inconsistent experience.

I think either we treat JSDoc comments as a marker of uniqueness (behind a default off flag) or we continue to ignore them.

@JoshuaKGoldberg
Copy link
Member

πŸ‘ agreed. Marking as accepting PRs for a default-off flag as a feature request for the rule.

@JoshuaKGoldberg JoshuaKGoldberg changed the title Bug: [unified-signatures] Should not warn when one signature is deprecated and one is not Feature: [unified-signatures] Option to not report when signature has different JSDoc Dec 30, 2024
@JoshuaKGoldberg JoshuaKGoldberg added enhancement New feature or request accepting prs Go ahead, send a pull request that resolves this issue and removed bug Something isn't working triage Waiting for team members to take a look labels Dec 30, 2024
@github-actions github-actions bot added the locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. label Mar 11, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement New feature or request locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
4 participants