Skip to content

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

Open
urbanfly wants to merge 2 commits intochodorowicz:mainfrom
urbanfly:feature/awaited
Open

Use Awaited type to avoid Promise<Promise<T>>#68
urbanfly wants to merge 2 commits intochodorowicz:mainfrom
urbanfly:feature/awaited

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