Skip to content

Bug: [no-unused-vars] Does not recognize usage in TS 4.7 "infer + extends" syntax #5330

Closed
@pmer

Description

@pmer

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=C4TwDgpgBAGlC8UDOwBOBLAdgcygHykwFcBbAIwlQG4AoG0SKASQBMAeAFQD4EoOoIAD2ARMLJFADeUdCwBcMzADNKzFgOGjxsKAF8oAfjVQFmCADdKtGiwgBjADYBDVNCVFMd4OgD2mKEqcXAAU5k4ORBAKHAA0MvJqQQCUCuY+stZKwdKyCgCMenEATEm0QA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tidmUQAmtAG4BDaKgwBtcNhyJo0DtEiyIAXVkBfEFqA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

type X = string | number;  // 'X' is defined but never used. 1:6 - 1:7

type Id<T> = T extends { id: infer Id extends X } ? Id : never;  // X is used here!

declare function f<T>(value: T, id: Id<T>): void;

f({ id: 1 }, 2);

ESLint Config

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

tsconfig

{
}

Expected Result

I expected no error.

Actual Result

There was an error on line 1.

Additional Info

This is using the new infer + extends syntax from TypeScript 4.7.

Versions

package version
@typescript-eslint/eslint-plugin 5.30.5
@typescript-eslint/parser 5.30.5
TypeScript 4.7.4
ESLint 8.19.0
node 18.4.0

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

      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