Skip to content

Conversation

jablko
Copy link
Contributor

@jablko jablko commented Nov 22, 2019

async function f<T>(x: T) {
    return x;
}
const expected: Promise<number> = f(undefined as Promise<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.

@jablko jablko force-pushed the patch-26 branch 2 times, most recently from 4dc37b5 to e78a9aa Compare February 3, 2020 15:28
@sandersn sandersn added the For Backlog Bug PRs that fix a backlog bug label Feb 3, 2020
@jablko jablko force-pushed the patch-26 branch 4 times, most recently from 866166b to fb42ba3 Compare February 10, 2020 20:01
@jablko jablko force-pushed the patch-26 branch 4 times, most recently from 9a424b4 to 600875a Compare February 13, 2020 15:42
@rbuckton
Copy link
Contributor

This was superseded by #45350

@rbuckton rbuckton closed this Mar 18, 2022
@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs 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