-
-
Notifications
You must be signed in to change notification settings - Fork 169
Closed
Description
The current jsdoc/require-returns implementation depends on the presence of a return statement, but an inconsistent case remains even when forceReturnsWithAsync is set to true.
It will be nice, at least in Typescript, to detect when async/await is used and the return is Promise<void> type. It strange and not very insightful document this case just because the type change from void to Promise. For example:
/**
* Do something.
*
* @throws {Error} If something bad occurs.
*/
function doFoo(): void {
// Do something.
}
/**
* Do something.
*
* @returns The promise that is resolved once something is completed.
*
* @throws {Error} If something bad occurs.
*/
async function doBar(): Promise<void> {
// Do something.
}
/**
* Do something.
*
* @returns The promise that is resolved once something is completed.
*
* @throws {Error} If something bad occurs.
*/
async function doBaz(): Promise<void> {
return new Promise<void>((resolve, reject) => {
// For some reason its more convenient at some point to return a contruction like this.
});
}
doFoo();
await doBar();
await doBaz();To me all methods are similar in structure and documentation. However, the rule makes mandatory to document the result in doBar() and/or doBaz().
It would be nice if you can configure the rule to avoid having to document Promise<void> return when using async / wait.