Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Typescript error from Result example #78

Open
assertnotnull opened this issue Mar 22, 2023 · 2 comments
Open

Typescript error from Result example #78

assertnotnull opened this issue Mar 22, 2023 · 2 comments

Comments

@assertnotnull
Copy link

Using version 3.13.1

There's a type mismatch between the Result functions

image

@JUSTIVE
Copy link

JUSTIVE commented Apr 25, 2023

It seems the example should change like this:

pipe(
  // ⬇️ const obj: User = { name: 'Joe', age: 20 }
  R.fromNullable(obj, String('cannot be nullable')),
  R.flatMap((obj) => {
    return G.isNotNullable(obj.name) ? R.Ok(obj) : R.Error(String('missing name'))
  }),
  R.map((obj) => `${obj.name} is ${obj.age} year old!`)
) // → Ok('Joe is 20 year old!')

Those literal strings are regarded as the type of itself instead of a string type.

@JUSTIVE
Copy link

JUSTIVE commented Jan 5, 2024

seems this issue is resolved in the ts-beltv4.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants