Skip to content

Bug: [no-unused-vars] Generic passed to class reference during class property assignment not picked up as being used. #5317

Closed
@stagas

Description

@stagas

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=4.7.4&sourceType=module&code=MYGwhgzhAEBiD28A8AVAfNA3gKGtAbmCAK4CmAXNCtgL7baiQwBCYATqhjngGaLQBeOIk616AO1IB3aKzYAKAJTYgA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tidmUQAmtAG4BDaKgwBtSImjQO0SAF1wYAL4h1QA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

class Foo<T> {
  value: T
}

class Bar<T> {
  foo = Foo<T>
}

new Bar()

ESLint Config

module.exports = {
  "rules": {
    "@typescript-eslint/no-unused-vars": ["error"]
  }
}

tsconfig

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

Expected Result

To pick up that T in foo = Foo<T> is being used.

Actual Result

'T' is defined but never used. 5:11 - 5:12

Additional Info

The ability to modify function references with generics is a new feature in TS 4.7, so this is probably the reason the rule hasn't updated yet to support it.

Versions

package version
@typescript-eslint/eslint-plugin 5.30.5
@typescript-eslint/parser 5.30.5
TypeScript 4.7.4
ESLint 8.15.0
node web

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinggood first issueGood for newcomerspackage: scope-managerIssues related to @typescript-eslint/scope-manager

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions