Closed
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Playground Link
Repro Code
abstract class A {
thing: number | null = null;
abstract setThing(): void;
setAndPrintThing(): void {
this.setThing();
console.log(this.thing);
}
}
class B extends A {
// Expected no-misused-promises error here
async setThing(): Promise<void> {
const thing = await fetchThing();
this.thing = thing;
}
}
async function fetchThing(): Promise<number> {
return await new Promise<number>((resolve) => {
setTimeout(() => {
resolve(5);
}, 1000);
});
}
const b = new B();
// Prints null instead of 5
b.setAndPrintThing();
function _setAndPrintThing(setThing: () => void): void {
setThing();
console.log(b.thing);
}
// Correctly triggers no-misused-promises error:
// "Promise returned in function argument where a void return was expected"
_setAndPrintThing(b.setThing.bind(this));
ESLint Config
{
"rules": {
"@typescript-eslint/no-misused-promises": "error"
}
}
tsconfig
Expected Result
Line 14 (where B.setThing
is implemented) should show an error like "Promise returned in abstract method implementation where a void return was expected"
Actual Result
There's no error on line 14
Additional Info
I'm not sure why the playground link doesn't seem to be working, but hopefully you can see my code sample anyway and it makes sense.
Based on the no-misused-promises
page it looks like maybe this should be another category under checksVoidReturn
?