Open
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 |