Skip to content

Bug: [no-unnecessary-type-parameters] Detects an error where there's none #9709

Closed as not planned
@lgenzelis

Description

@lgenzelis

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.3&showAST=scope&fileType=.tsx&code=C4TwDgpgBAwg9gWzAV2BAPAQQHxQLxSZQQAeaAdgCYDOUAYsuQMbACWc5UA-IVAFxQA3lADaAaSitOAawgg4AM0IBdAfCSoMmcctwBfANwAoI6EhQAogEdkAQwA26ABoAaKAE1ceI1CgAKdAAVAEZsPwBKfFwQ4jIIKlp1FDRnXB5g-igAJkjSChooIKywyLxorNj8xMRkjE9uKAyBCp5gACdkaAEFB2oIYyMgA&eslintrc=N4KABGBEBOCuA2BTAzpAXGYUACAXAngA4oDG0AlobgLQrzkB2uA9AwPbWwMOIkrIBDaPmoFi1QkIEBbRLkTRUGSAuhtokAL4hNQA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

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

{
  "compilerOptions": {
    "strictNullChecks": true
  }
}

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):

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglocked due to agePlease 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-plugintriageWaiting for team members to take a lookwontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy