pratica
pratica copied to clipboard
Result should require a non empty value
I think Result should require a defined value on its creation in order to guarantee a value in cata
.
ie,
const format= (text: string): Result<number, string> => {
const number = Number(text)
return isNaN(number)? Err('bad input') : Ok(number)
}
format('2,000').cata({
Ok: (result)=> // result is not guaranteed, can be undefined
Err:// ...
})
format's output is a Result number, but still, we have to add a conditional guard to fix the type.
Left a comment on your PR https://github.com/rametta/pratica/pull/30/files#r992399077, let me know what you think
hey Jason, thank you for taking the time to review this. How would you use NonNullable in this case?
I also ran into this issue. What do you think of https://github.com/rametta/pratica/pull/31?
I also ran into this issue. What do you think of #31?
Looks good, just a few comments on it then we can merge
This is now fixed and available in version 2.1.0 on npm.