-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
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
Repro Code
type Foo<T, S> = S extends "somebody"
? T extends "once"
? "told"
: "me"
: never;
declare function foo<T>(data: T): <S>(other: S) => Foo<T, S>;
ESLint Config
module.exports = {
parser: "@typescript-eslint/parser",
rules: {
"@typescript-eslint/no-unnecessary-type-parameters": "error",
},
};
tsconfig
No response
Expected Result
T shouldn't be surfaced by this rule; it has a meaningful usage in the type definitions.
Actual Result
T is surfaced as only being used once, incorrectly.
Additional Info
I maintain the Remeda typescript utility library. We rely heavily on curried functions, which are functions that return functions. The rule is firing for almost all our complex types where the type is passed on to the return type of the curried function. The non-curried functions, which are identical in terms of how the type param is used, are not falsely detected, so this has something to do with the param being passed on "through" to the return type of its returned function type.
When trying to reproduce this, I noticed that simpler cases where the T is used directly in the type aren't falsely detected; the issue can only be reproduced once we start introducing ternary conditions on other type params.
You can see a fuller example via the PR, which tries to introduce this rule into our codebase: remeda/remeda#801