Skip to content

Forbid non-promise types in @return on async functions #1345

Open
@Daimona

Description

@Daimona

Motivation

async functions always return promises, and can never return anything else. Therefore, documenting an async function as @return {T} is always wrong, unless T is (a subtype of) Promise.

Current behavior

The existing rules do not flag those return tags as incorrect. This problem was also mentioned in #452 (comment).

Desired behavior

I would like to receive a warning if an async function is annotated as returning a non-promise. This could be part of an existing rule (presumably in the require-return* family) or a new rule. Either would work.

Alternatives considered

If checking for non-promises in general is too complicated, it would be great to at least check native types for the time being. So warn for @return {string}, @return {void} etc., but ignore @return {SomeCustomType}.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions