-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Comments
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. |
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. |
If we entertain this, then I'd ask whether we should generally consider signatures that have different JSDocs π€.... /**
* This signature does something.
*/
declare function f(x: number): void;
/**
* This signature does something else.
*/
declare function f(x: string): void; |
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. |
π agreed. Marking as accepting PRs for a default-off flag as a feature request for the rule. |
Before You File a Bug Report Please Confirm You Have Done The Following...
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
ESLint Config
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
Additional Info
No response
The text was updated successfully, but these errors were encountered: