Skip to content

Conversation

@jablko
Copy link
Contributor

@jablkojablko commented Nov 22, 2019

asyncfunctionf<T>(x: T){returnx;}constexpected: Promise<number>=f(undefinedasPromise<number>);

Before

!!! error TS2322: Type 'Promise<Promise<number>>' is not assignable to type 'Promise<number>'. !!! error TS2322: Type 'Promise<number>' is not assignable to type 'number'. 

After

getAwaitedType() returns the awaited type if it's known, or Awaited<T> if it's generic.

Fixes#27711

This proposal excludes non-A+ promises, which has the benefit of not requiring a recursive solution or a new kind of type, since an A+ promise can't resolve to another promise.

@typescript-bot test this
@typescript-bot run dt
@typescript-bot user test this

@orta
Copy link
Contributor

orta commented Jan 29, 2020

@typescript-bot test this
@typescript-bot user test this
@typescript-bot run dt

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 29, 2020

Heya @orta, I've started to run the extended test suite on this PR at 3bab709. You can monitor the build here. It should now contribute to this PR's status checks.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 29, 2020

Heya @orta, I've started to run the parallelized Definitely Typed test suite on this PR at 3bab709. You can monitor the build here. It should now contribute to this PR's status checks.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 29, 2020

Heya @orta, I've started to run the parallelized community code test suite on this PR at 3bab709. You can monitor the build here. It should now contribute to this PR's status checks.

@typescript-bot
Copy link
Collaborator

The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master.

@jablkojablko mentioned this pull request Jan 31, 2020
@jablkojablkoforce-pushed the patch-26 branch 2 times, most recently from 4dc37b5 to e78a9aaCompareFebruary 3, 2020 15:28
@sandersnsandersn added the For Backlog Bug PRs that fix a backlog bug label Feb 3, 2020
@jablkojablkoforce-pushed the patch-26 branch 4 times, most recently from 866166b to fb42ba3CompareFebruary 10, 2020 20:01
@jablkojablkoforce-pushed the patch-26 branch 4 times, most recently from 9a424b4 to 600875aCompareFebruary 13, 2020 15:42
@rbuckton
Copy link
Contributor

This was superseded by #45350

@typescript-bot
Copy link
Collaborator

The TypeScript team hasn't accepted the linked issue #27711. If you can get it accepted, this PR will have a better chance of being reviewed.

@microsoftmicrosoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Backlog BugPRs that fix a backlog bug

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Promise<Promise<T>> cannot exist in JS

5 participants

@jablko@orta@typescript-bot@rbuckton@sandersn