Skip to content

awaited operator is not added to the return types of async functions #37592

Description

TypeScript Version: 3.7.x-dev.201xxxxx

Search Terms:

Code

async function f<T>(a: T): Promise<T> {
    return a;
}
async function g<T>(a: T) {
    return a;
}
g(Promise.resolve(0));

Expected behavior:
Return type of f is invalid because the correct type is Promise<awaited T>.
Return types of g are Promise<awaited T> and Promise<number>.
Actual behavior:
Return type of f is valid although the correct type is Promise<awaited T>.
Return types of g are Promise<T> and Promise<Promise<number>>.

Playground Link: https://www.typescriptlang.org/play/index.html?ts=3.9.0-dev.20200324&ssl=1&ssc=1&pln=7&pc=23#code/IYZwngdgxgBAZgV2gFwJYHsLwDwBUB8AFMAFwy4CUZACgE7oC2qIApnvjAN4BQMfMtFsgS0swANzcAvt1CRYiFBiwBzdsTKUuvfoOGiYE6dxWE6jZiwB0gkOgA2ANxaEADBQrigA

Related Issues:

Activity

  1. falsandtru commented on Mar 25, 2020

    @falsandtru
    ContributorAuthor

    Ron Buckton (@rbuckton) Andrew Casey (@amcasey) Ryan Cavanaugh (@RyanCavanaugh) Nathan Shively-Sanders (@sandersn) Since this bug would easily make wrong errors in user tests, this should be fixed soon.

  2. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions