Skip to content

Bug: [no-extra-parens] False positive when calling generic function with type parameter with parentheses #5488

Closed
@xsjcTony

Description

@xsjcTony

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&jsx=true&sourceType=module&code=CYUwxgNghgTiAEYD2A7AzgF3gMwFzwB4AVAPgAoAPfIgSngF4T4oUBPAWACgvsCyUArgFsARiBjwAPvEwwAligDmNANoBdcioDkULQBp4ARjU0gA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge3oA99oBDWsX7RETVBkiJo0DtEjgwAXxBKgA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eFYDAruuGAL4g9A

Repro Code

declare const f: <T>(x: T) => any

f<(number | string)[]>(['a', 1])

ESLint Config

{
  "rules": {
    "@typescript-eslint/no-extra-parens": "error"
  }
}

tsconfig

{
  "compilerOptions": {
    "strict": true
  }
}

Expected Result

No error

Actual Result

@typescript-eslint/no-extra-parens: Unnecessary parentheses around expression. 3:23 - 3:24

Additional Info

Related to #2314

Versions

package version
@typescript-eslint/eslint-plugin 5.33.1
@typescript-eslint/parser 5.33.1
TypeScript 4.7.4
ESLint 8.22.0
node 16.16.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingformattingRelated to whitespace/bracket formatting. We strongly recommend you use a formatter instead.package: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions