Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.9k
Open
Description
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I haveread the FAQ and my problem is not listed.
Repro
interfaceFoo{unbound():number;unboundOk(this:void):number;bound:()=>number;}functionwhat(f:Foo){constunbound=f.unbound;// lint error 👍constunboundOk=f.unboundOk;// no error 👍constbound=f.bound;// no error 👍// console.log(unbound()); // runtime error (expected)console.log(unboundOk());// runtime error ❌console.log(bound());// runtime error ❌}classExampleimplementsFoo{x=3;unbound(){returnthis.x;}unboundOk(){returnthis.x;}// no error 👎 (TypeScript issue rather than typescript-eslint issue?)bound(){returnthis.x;}// no error 👎 (this issue)}what(newExample());
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 onbound() { return this.x } when is used to satisfy the interface requirementbound: () => 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 |