-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Promise of promise type is somehow possible #26839
Labels
Duplicate
An existing issue was already created
Comments
Workaround: async function fn<X>(x: PromiseLike<X>): Promise<X> // You can change PromiseLike to Promise
async function fn<X>(x: X): Promise<X>
async function fn<X>(x: X) {
return await x
}
const foo = fn(123) // Promise<number>
const bar = fn(foo) // Promise<number>
const baz = fn(Promise.resolve('abc')) // Promise<string> |
Simplified workaround: async function fn<X>(x: PromiseLike<X> | X) {
return await x
}
const foo = fn(123) // Promise<number>
const bar = fn(foo) // Promise<number>
const baz = fn(Promise.resolve('abc')) // Promise<string> |
RyanCavanaugh
added
the
Needs Investigation
This issue needs a team member to investigate its status.
label
Sep 17, 2018
I just triaged #27711 so forwarding to that. |
DanielRosenwasser
added
Duplicate
An existing issue was already created
and removed
Needs Investigation
This issue needs a team member to investigate its status.
labels
Oct 25, 2018
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TypeScript Version: 3.0.0
Search Terms:
Code
Expected behavior:
bar
andbaz
should bePromise<number>
andPromise<string>
respectively.Actual behavior:
They are
Promise<Promise<number>>
andPromise<Promise<string>>
Playground Link: link
Related Issues:
The text was updated successfully, but these errors were encountered: