Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[no-extra-parens] False positive when calling generic function with single argument and type parameter with parentheses #2314

Closed
Labels
bugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin
@cherryblossom000

Description

@cherryblossom000

Repro

{"rules": {"@typescript-eslint/no-extra-parens":2  }}
declare module'test'{classC{}export=C}declareconstf:<T>(x:any)=>anyf<import('test')>(1)

Expected Result

No errors becausef<import('test')>1 isn't valid syntax.

Actual Result

8:18  error  Unnecessary parentheses around expression  @typescript-eslint/no-extra-parens

Additional Info

This seems to be because ofgetParentSyntaxParen used inisParentheszied in eslint-utils. Normally, the1 inf(1) isn't considered to be parenthesised because the( to the left of1 is the same the first( afterf. Withf<import('test')>(1), the first( afterf is the one used inimport('test'), so1 is reported for being an unnecessarily parenthesised literal.

This function is used in ESLint inisParenthesized ->hasExcessParensWithPrecedence ->checkCallNew.

This could be fixed by reducing the precedence of the argument node.

Versions

packageversion
@typescript-eslint/eslint-plugin3.7.0
@typescript-eslint/parser3.7.0
TypeScript3.9.7
ESLint7.5.0
node12.18.2
npm6.14.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage: 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


      [8]ページ先頭

      ©2009-2025 Movatter.jp