-
-
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 newcomershas prthere is a PR raised to close thisthere is a PR raised to close thispackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin
Description
Repro
{
"rules": {
"@typescript-eslint/prefer-function-type": 2
}
}
interface Interface {(): this}
Expected Result
No error as this
can only be used in a class or interface.
Actual Result
/path/to/file.ts
1:22 error Interface has only a call signature - use 'type Interface = () => this' instead @typescript-eslint/prefer-function-type
✖ 1 problem (1 error, 0 warnings)
1 error and 0 warnings potentially fixable with the `--fix` option.
Additional Info
Running eslint with --fix
results in this code:
type Interface = () => this
which causes a tsc
error:
file.ts:1:24 - error TS2526: A 'this' type is available only in a non-static member of a class or interface.
1 type Interface = () => this
~~~~
Found 1 error.
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
2.24.0 |
@typescript-eslint/parser |
2.24.0 |
TypeScript |
3.7.5 |
ESLint |
6.8.0 |
node |
12.11.0 |
npm |
6.11.3 |
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershas prthere is a PR raised to close thisthere is a PR raised to close thispackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin