Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Closed
Description
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-parensAdditional 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
| package | version |
|---|---|
@typescript-eslint/eslint-plugin | 3.7.0 |
@typescript-eslint/parser | 3.7.0 |
TypeScript | 3.9.7 |
ESLint | 7.5.0 |
node | 12.18.2 |
npm | 6.14.5 |