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

备稿计划: TypeScript 支持 Awaited<T> #100

Open
iugo opened this issue Sep 10, 2021 · 0 comments
Open

备稿计划: TypeScript 支持 Awaited<T> #100

iugo opened this issue Sep 10, 2021 · 0 comments

Comments

@iugo
Copy link
Member

iugo commented Sep 10, 2021

之前, Promise 和 Promise<Promise> 是两个不同的类型.

以前, Promise<Promise<T>>.then(v => type v is Promise<T>).
想要解决这个问题可以通过 await Promise<Promise<T>> 拿到 T.

现在, 终于可以不用再为这个操心了.

microsoft/TypeScript#45350

用法举例: https://www.typescriptlang.org/play?ts=4.5.0-dev.20210910#code/C4TwDgpgBGULxQAoCcD2BbAlgZwgHgDsBXdAIwmQD4BuAKFEigEN4oBBAdyc2AgBM8YGrSA

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

No branches or pull requests

1 participant