Hi there,
I had a quick play around with the library and noticed the return types aren't reflecting the runtime values when switching from sync to async code.
import { Result } from '@praha/byethrow';
const doublePlusFive = Result.pipe(
// ^?
// (sync) initial value
Result.succeed(5),
// (sync -> async) return a promise to cross into async code
Result.map((x) => {
return Promise.resolve(x * 2);
}),
// (async) map the value from the previous step
Result.map((x) => {
// ^?
return x + 5; // x is actually 10 here at runtime, but types suggest it's a promise
})
);
// test is actually a promise returning a Result at runtime, but types suggest it's a sync Result
Playground link
To be honest I'm not confident it's possible to get the types for this to work properly without having separate sync and async implementations of every function. But hopefully it's an easy fix or I'm just doing something incorrectly.
Hi there,
I had a quick play around with the library and noticed the return types aren't reflecting the runtime values when switching from sync to async code.
Playground link
To be honest I'm not confident it's possible to get the types for this to work properly without having separate sync and async implementations of every function. But hopefully it's an easy fix or I'm just doing something incorrectly.