FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Defer generic awaited type by jablko · Pull Request #35284 · microsoft/TypeScript · GitHub

Defer generic awaited type - #35284

Closed
Jack Bates (jablko) wants to merge 2 commits into
microsoft:mainfrom
jablko:patch-26
Closed

Defer generic awaited type#35284
Jack Bates (jablko) wants to merge 2 commits into
microsoft:mainfrom
jablko:patch-26

Conversation

Jack Bates (jablko) commented Nov 22, 2019
edited
Loading

Copy link
Copy Markdown
Contributor
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 (@typescript-bot) test this
TypeScript Bot (@typescript-bot) run dt
TypeScript Bot (@typescript-bot) user test this

Copy link
Copy Markdown
Contributor

TypeScript Bot (@typescript-bot) test this
TypeScript Bot (@typescript-bot) user test this
TypeScript Bot (@typescript-bot) run dt

TypeScript Bot (typescript-bot) commented Jan 29, 2020
edited
Loading

Copy link
Copy Markdown
Contributor

Heya Orta Therox (@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 (typescript-bot) commented Jan 29, 2020
edited
Loading

Copy link
Copy Markdown
Contributor

Heya Orta Therox (@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 (typescript-bot) commented Jan 29, 2020
edited
Loading

Copy link
Copy Markdown
Contributor

Heya Orta Therox (@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.

Copy link
Copy Markdown
Contributor

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

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

Copy link
Copy Markdown
Contributor

This was superseded by #45350

Copy link
Copy Markdown
Contributor

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.

Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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


Back | FazBrowse Home | New Git URL