-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Open
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin ruleNew rule option for an existing eslint-plugin rulepackage: 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
interface Foo {
unbound(): number;
unboundOk(this: void): number;
bound: () => number;
}
function what(f: Foo) {
const unbound = f.unbound; // lint error 👍
const unboundOk = f.unboundOk; // no error 👍
const bound = f.bound; // no error 👍
// console.log(unbound()); // runtime error (expected)
console.log(unboundOk()); // runtime error ❌
console.log(bound()); // runtime error ❌
}
class Example implements Foo {
x = 3;
unbound() { return this.x; }
unboundOk() { return this.x; } // no error 👎 (TypeScript issue rather than typescript-eslint issue?)
bound() { return this.x; } // no error 👎 (this issue)
}
what(new Example());eslint config: https://github.com/foxglove/eslint-plugin/blob/main/configs/typescript.js
tsconfig: https://github.com/foxglove/studio/blob/main/packages/tsconfig/tsconfig.base.json
Expected Result
class Example implements Foo is problematic. There should be an error on bound() { return this.x } when is used to satisfy the interface requirement bound: () => number;.
Actual Result
The lint rule does not reject this incorrect method implementation, which leads to a runtime error.
Versions
| package | version |
|---|---|
@typescript-eslint/eslint-plugin |
4.26.0 |
@typescript-eslint/parser |
4.26.0 |
TypeScript |
4.3.2 |
ESLint |
7.27.0 |
node |
15.9.0 |
kirkwaiblinger
Metadata
Metadata
Assignees
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin ruleNew rule option for an existing eslint-plugin rulepackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin