Closed as not planned
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 Compute<A> = A extends Function ? A : { [K in keyof A]: Compute<A[K]> };
type Equal<X, Y> =
(<T1>() => T1 extends Compute<X> ? 1 : 2) extends <T2>() => T2 extends Compute<Y> ? 1 : 2 ? true : false;
ESLint Config
module.exports = {
"rules": { "@typescript-eslint/no-unnecessary-type-parameters": "error"}
}
tsconfig
Expected Result
I wouldn't expect this to give any errors. As far as I can tell, there's no way to achieve the same functionality without adding <T1>
and <T2>
.
Actual Result
I'm getting two errors (one for each T
):
- Type parameter T1 is used only once.ESLint @typescript-eslint/no-unnecessary-type-parameters
- Type parameter T2 is used only once.ESLint@typescript-eslint/no-unnecessary-type-parameters
Additional Info
In all honesty, I don't understand how that Equal
utility type works. But I know it does: it returns true
if X
and Y
are assignable to one another (and if one is any
, only if the other one is any
as well). I have been using it in my codebase for a while.