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

New Type "AsyncReturnType" #167

Open
VanCoding opened this issue Jun 28, 2021 · 0 comments
Open

New Type "AsyncReturnType" #167

VanCoding opened this issue Jun 28, 2021 · 0 comments

Comments

@VanCoding
Copy link

Is your feature request related to a real problem or use-case?

When we have an async function like this:

async function getDataFromAPI(){
  return {a:1,b:2}
}

To get the return type, we currently have to do this:
type APIData = PromiseType<ReturnType<typeof getDataFromAPI>>

This is a bit hard to read IMO.

Describe a solution including usage in code example

If we had an utility Type that combines these two types called "AsyncReturnType", we could make it shorter and more readable like that:

type APIData = AsyncReturnType<typeof getDataFromAPI>

Who does this impact? Who is this for?

I think this would be beneficial for all people who want to get the return type of an async function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant