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
function b() {
return Math.random() ? 'one' : Promise.resolve(1);
}
ESLint Config
_playground default_
tsconfig
Expected Result
No reports
Actual Result
"Functions that return promises must be async."
Attempts to fix to async function
, changing the return type from A | Promise<B>
to Promise<A | B>
Additional Info
While this behavior is described in the docs/demo, I believe it's wrong because the function does not "return a promise," it only "MAY return a promise."
The change requested is unsafe as it changes the signature/type of the function entirely.
Note that whether () => A | Promise<B>
is a good type is not relevant to this issue. The type exists in the wild (web extensions, screenshot) and it can be prohibited by a separate rule (suggested here)