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

Use Awaited type to avoid Promise<Promise<T>> #68

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

urbanfly
Copy link

@urbanfly urbanfly commented Dec 5, 2024

When debouncing a Promise-returning function, the returned function has a type of Promise<Promise<T>> which is not accurate - see microsoft/TypeScript#27711

In TypeScript 4.5, a new Awaited<T> type was introduced to solve this problem.

This PR simply wraps the ReturnType<F> with Awaited<...> in order to get an accurate return type for the created function.

Several packages were updated:

  • Typescript bumped to 4.5 in order to access this type
  • microbundle in order to build
  • jest / ts-jest in order to test with this type
  • tsd in order to validate the types

@urbanfly urbanfly changed the title Use Awaited type to avoide Promise<Promise<T>> Use Awaited type to avoid Promise<Promise<T>> Dec 5, 2024
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

Successfully merging this pull request may close these issues.

1 participant