Closed
Description
Repro
{
"rules": {
"@typescript-eslint/no-extra-parens": 2
}
}
declare module 'test' {
class C {}
export = C
}
declare const f: <T>(x: any) => any
f<import('test')>(1)
Expected Result
No errors because f<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 of getParentSyntaxParen
used in isParentheszied
in eslint-utils. Normally, the 1
in f(1)
isn't considered to be parenthesised because the (
to the left of 1
is the same the first (
after f
. With f<import('test')>(1)
, the first (
after f
is the one used in import('test')
, so 1
is reported for being an unnecessarily parenthesised literal.
This function is used in ESLint in isParenthesized
-> 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 |