Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
falsandtru opened this issue Mar 25, 2020 · 1 comment · Fixed by #37610
Closed

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

falsandtru opened this issue Mar 25, 2020 · 1 comment · Fixed by #37610

Comments

@falsandtru
Copy link
Contributor

falsandtru commented Mar 25, 2020

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:

@falsandtru falsandtru changed the title awaited operator is not added to return types of async functions awaited operator is not added to the return types of async functions Mar 25, 2020
@falsandtru
Copy link
Contributor Author

@rbuckton @amcasey @RyanCavanaugh @sandersn Since this bug would easily make wrong errors in user tests, this should be fixed soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant