I've found an issue with the typing of EitherAsync.map.
When returning a Promise<T> in de the map function typescript tells us that the new type is EitherAsync<Promise<T>>.
But in actuality the type should be EitherAsync<T>, the Promise<T> gets unwrapped to T just like with a regular promise.then(...).
Example:
EitherAsync(() => Promise.resolve(null))
.map(() => Promise.resolve('yeet'))
.map(value => {
// Typescript says this is a `Promise` but the promise actually gets unwrapped, so it is a `string` instead
console.log(typeof value);
});
I've found an issue with the typing of EitherAsync.map. When returning a
Promise<T>
in de the map function typescript tells us that the new type isEitherAsync<Promise<T>>
. But in actuality the type should beEitherAsync<T>
, thePromise<T>
gets unwrapped toT
just like with a regularpromise.then(...)
.Example:
Current incorrect typing of map:
Proposed correct typing of map: