-
-
Notifications
You must be signed in to change notification settings - Fork 554
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
Make the PromiseValue
type handle nested promises
#112
Conversation
Shouldn't |
So I decided to post the changes first and see how people think about this. |
Are you aware that they plan to solve this problem in TypeScript itself? microsoft/TypeScript#27711 (comment) |
I doubt it will break in the future, but if so, we could probably find a workaround. |
I did look at that issue. The problem is that the official support won't be available before TS 4.0. Before TS people have solved the problem, it is necessary to have this type as a temporary workaround. I do wish to alter the behaviour of |
PromiseValueRecursive
typePromiseValue
type handle nested promises
As per this discussion, a more realistic use case of unwrapping a type from Promise is when the Promise is resolved to another Promise.
For example,
await Promise.resolve(Promise.resolve(2))
is resolved asnumber
, notPromise<number>
. The current typePromiseValue
however, does not reflect this behaviour.Thanks to Gerrit0 who shared the trick, I stole his brilliant idea and brought to this package.