-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomerspackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin
Description
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have read the FAQ and my problem is not listed.
Repro
{
"rules": {
"@typescript-eslint/non-nullable-type-assertion-style": "error"
}
}
import rewire from 'rewire'
const rewiredModule = rewire('./example-module')
const someFunction = rewiredModule.__get__('myFunc') as (() => void)
Expected Result
This rule warns about the rewiredModule.__get__('myFunc') as (() => void)
part. According to #2887 (comment), this is expected. As __get__
is a function with a generic type only used in the return type (see here), I'd expect no autofix in this case, or this one:
import rewire from 'rewire'
const rewiredModule = rewire('./example-module')
- const someFunction = rewiredModule.__get__('myFunc') as (() => void)
+ const someFunction = rewiredModule.__get__<() => void>('myFunc')
Actual Result
The autofix applies this (wrong) change:
import rewire from 'rewire'
const rewiredModule = rewire('./example-module')
- const someFunction = rewiredModule.__get__('myFunc') as (() => void)
+ const someFunction = rewiredModule.__get__('myFunc')!
Additional Info
The rewire
module's source code: https://github.com/jhnns/rewire
As already suggested, the autofix could just become a suggestion instead.
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
4.31.1 |
@typescript-eslint/parser |
4.31.1 |
TypeScript |
4.3.4 |
ESLint |
7.32.0 |
node |
12.22.6 |
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomerspackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin