Thursday 26 November 2020

How to unwrap a promise in a JSDoc type with ReturnType?

I have the following code:

const foo = async () => {
  return 1
}

I want to add a type to a variable with the ReturnType of the function, but the type after resolving the promise.

If I try:

/** @type {ReturnType<foo>} */
let bar

I get Promise<number>, but I want to get number.

Is it possible to achieve this result in JSDoc? How?



from How to unwrap a promise in a JSDoc type with ReturnType?

No comments:

Post a Comment