Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
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 havesearched for related issues and found none that matched my issue.
- I haveread the FAQ and my problem is not listed.
Playground Link
Repro Code
functionf():void;functionf(x:string):string;functionf(x?:string):void|string{if(x!==undefined){returnx;}}functiong():Promise<void>;functiong(x:string):Promise<string>;asyncfunctiong(x?:string):Promise<void|string>{if(x!==undefined){returnx;}}
ESLint Config
module.exports={"rules":{"@typescript-eslint/no-invalid-void-type":"error"}}
tsconfig
{}
Expected Result
No errors.
Actual Result
void is only valid as a return type or generic type variable. 3:25 - 3:29
void is only valid as a return type or generic type variable. 11:39 - 11:43
Additional Info
It's possible to work around the linter in the first example by changing the implementation return type fromvoid | ...
toundefined | ...
, although this may require introducing an explicitreturn undefined
statement to the function body if the compiler optionnoImplicitReturns
is set.
In the second example, changingPromise<void | ...>
toPromise<undefined | ...>
is not possible because it introduces a compiler error
This overload signature is not compatible with its implementation signature. (2394)
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin | 5.39.0 |
@typescript-eslint/parser | 5.39.0 |
TypeScript | 4.8.4 |
ESLint | 8.15.0 |
node | web |