Skip to content
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

Expose TypeChecker. getAwaitedType to public #59268

Merged
merged 5 commits into from
Aug 19, 2024

Conversation

yeonjuan
Copy link
Contributor

Fixes #59256

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Jul 14, 2024
@typescript-bot
Copy link
Collaborator

Looks like you're introducing a change to the public API surface area. If this includes breaking changes, please document them on our wiki's API Breaking Changes page.

Also, please make sure @DanielRosenwasser and @RyanCavanaugh are aware of the changes, just as a heads up.

@yeonjuan
Copy link
Contributor Author

@microsoft-github-policy-service agree

@yeonjuan yeonjuan requested a review from jakebailey August 16, 2024 04:10
@typescript-bot typescript-bot added For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Aug 16, 2024
@jakebailey jakebailey requested a review from rbuckton August 16, 2024 17:04
@jakebailey
Copy link
Member

I think my only question left is whether or not getPromisedTypeOfPromise is the one that should be exported; it was used in #59316 in favor of getAwaitedType. Not 100% certain this case is the same.

@rbuckton
Copy link
Member

rbuckton commented Aug 16, 2024

getPromisedTypeOfPromise does not account for generics, e.g., the "promised type" of Promise<T> is T, even though T could be instantiated with something like a Promise<number>. getAwaitedType accounts for generics, as it will also get the "promised type" but will wrap the result in Awaited<T> if the "promised type" is generic.

@rbuckton
Copy link
Member

That said, if we expose getAwaitedType we might want to consider also exposing unwrapAwaitedType in the event you actually want the T.

@jakebailey
Copy link
Member

Ah, gotcha. I think people are mainly wanting to simulate the result of the await operator, so in that sense this function seems correct (and I have some PRs to ts-eslint that would use it).

src/compiler/types.ts Outdated Show resolved Hide resolved
jakebailey and others added 3 commits August 16, 2024 16:43
@jakebailey
Copy link
Member

Updated the PR; I'm hoping to sneak this in to 5.6, given this function's been exported for a while now so this is really just a doc change... @DanielRosenwasser do you think it's too late for this sort of change?

@jakebailey jakebailey requested a review from rbuckton August 16, 2024 23:45
@jakebailey
Copy link
Member

For reference, this function was first added to TypeChecker in #36654, so has been available since TS 4.0.

@jakebailey jakebailey merged commit 936a79b into microsoft:main Aug 19, 2024
30 checks passed
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
Status: Done
Development

Successfully merging this pull request may close these issues.

Expose TypeChecker.getAwaitedType for public api
4 participants