mobily / ts-belt

🔧 Fast, modern, and practical utility library for FP in TypeScript.
https://mobily.github.io/ts-belt
MIT License
1.1k stars 30 forks source link

why does `R.map` expect a non-nullable result? #61

Closed alphashuro closed 1 year ago

alphashuro commented 1 year ago

If I'm fetching an array from a server, and need to find an element in the array before returning the result, I would expect that I could return Result<Option<Elem>>, but instead R.map(A.getBy(/*...*/)) fails to pass type-checks because R.map expects a non-nullable result from its parameter.

Am I misunderstanding how I'm supposed to be achieving this? Is there something wrong with having an Option inside a Result?

mobily commented 1 year ago

@alphashuro thanks for reporting this issue, I believe it's been already fixed in v4.0.0 (RC), please install it with the next tag (yarn add @mobily/ts-belt@next)