-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin ruleNew rule option for an existing eslint-plugin rulelocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I have searched for related issues and found none that match my proposal.
- I have searched the current rule list and found no rules that match my proposal.
- I have read the FAQ and my problem is not listed.
My proposal is suitable for this project
- I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).
Link to the rule's documentation
https://typescript-eslint.io/rules/no-unnecessary-type-parameters/
Description
For purposes of counting whether a generic type parameter is used twice, T[]
/ Array<T>
should only count as using it once. I'm not aware of any realistic scenario where this would lead to a false positive.
We decided to defer this to a follow-up in the initial implementation (see links below). So here's an official request for the follow-up.
Fail
declare function getLength<T>(xs: readonly T[]): number;
Pass
declare function getLength(xs: readonly unknown[]): number;
Additional Info
See https://twitter.com/jfet97/status/1810703565280759964 and #8173 (comment) for context on why this doesn't work as expected today.
See #8173 (comment) for previous discussion of special-casing Array
and friends.
See #8173 (review) for a contrived example of how this could yield a false positive for Map
.
kirkwaiblinger and jfet97
Metadata
Metadata
Assignees
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin ruleNew rule option for an existing eslint-plugin rulelocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin