Skip to content

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

Closed
@falsandtru

Description

@falsandtru

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:

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