Skip to content

Bug: [no-unnecessary-type-parameters] false positive when used in the implementation of the method #9828

@ST-DDT

Description

@ST-DDT

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.5.4&fileType=.ts&code=KYDwDg9gTgLgBAMwK4DsDGMCWEVxsAZxgB4AVOUfFAEwLiKkxQHMA%2BACgFtgYALCagC44pAJTCGTZnADeAWABQcOGhxE4AQyjM6AXjgByA5rqkA3IuVQeSKLm58BcANSbtBCwoC%2BQA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tiacTJTIAhtEK0ipWsRFCAtonyJoqDJCXQO0SODABfELqA&tsconfig=N4XyA&tokens=false

Repro Code

export function test<T extends string>(method: T): string {
  const args = '' as T;
  return method + args;
}

ESLint Config

{
  "rules": {
    "@typescript-eslint/no-unnecessary-type-parameters": "error"
  }
}

tsconfig

{}

Expected Result

No Error

Actual Result

Type parameter T is used only once in the function signature.eslint@typescript-eslint/no-unnecessary-type-parameters

Additional Info

Original Code: https://github.com/faker-js/faker/blob/cc7715bebded681655b95f5afc368cb250a2eadf/test/support/seeded-runs.ts#L172-L192

The error was first observed in v8.1.0 it does not appear in 7.18.0

The rule seems to ignore any usage of the type inside the actual implementation.

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-pluginworking as intendedIssues that are closed as they are working as intended

    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