Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play/#ts=5.5.2&fileType=.tsx&code=JYOwLgpgTgZghgYwgAgBIHt0GsBiBXEBMYdEAHgBVkIAPSEAEwGdkA3dYB5AHzUy2QBeNhwYA%2BZAG8AsAChkyABQwQALiUBKIRPacN6igG45C5Ws3bkABSjoAtsCYQyu8fuRG5AXzlyEAGzgmFgxsKR9ZOQYIALgoFFY45AAjCBh0eIBRRAALdVDcAiIScgKxY0jZVPSs3MVFLUEJSWQvDQq5aoyIbIQcxSCAT0ILJqlW9rkgA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6ZfKsugNwHtKAE1rRE%2BWNCbooAdwCGkyODABfECqA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false
Repro Code
interface HookFunction<T extends void | Hook = void> {
(fn: () => void): T;
(fn: () => Promise<void>): T;
}
class Hook {}
declare var beforeEach: HookFunction<Hook>;
beforeEach(() => {});
beforeEach(async () => { });
ESLint Config
module.exports = {
parser: "@typescript-eslint/parser",
rules: {
"@typescript-eslint/strict-void-return": "warn"
};
tsconfig
Expected Result
beforeEach(async () => { }); should be valid because the parameter type is a function that returns a Promise.
Actual Result
beforeEach(async () => { }); produces a warning because the parameter is considered to be a function that returns void.
Additional Info
The specific case where I encountered this problem is with Mocha's beforeEach method.
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/49a2604fdf497676f6bc005b4869729d5b0d05bd/types/mocha/index.d.ts#L392
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play/#ts=5.5.2&fileType=.tsx&code=JYOwLgpgTgZghgYwgAgBIHt0GsBiBXEBMYdEAHgBVkIAPSEAEwGdkA3dYB5AHzUy2QBeNhwYA%2BZAG8AsAChkyABQwQALiUBKIRPacN6igG45C5Ws3bkABSjoAtsCYQyu8fuRG5AXzlyEAGzgmFgxsKR9ZOQYIALgoFFY45AAjCBh0eIBRRAALdVDcAiIScgKxY0jZVPSs3MVFLUEJSWQvDQq5aoyIbIQcxSCAT0ILJqlW9rkgA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6ZfKsugNwHtKAE1rRE%2BWNCbooAdwCGkyODABfECqA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false
Repro Code
ESLint Config
tsconfig
{ "compilerOptions": { "strictNullChecks": true } }Expected Result
beforeEach(async () => { });should be valid because the parameter type is a function that returns aPromise.Actual Result
beforeEach(async () => { });produces a warning because the parameter is considered to be a function that returns void.Additional Info
The specific case where I encountered this problem is with Mocha's
beforeEachmethod.https://github.com/DefinitelyTyped/DefinitelyTyped/blob/49a2604fdf497676f6bc005b4869729d5b0d05bd/types/mocha/index.d.ts#L392