fp-ts / optic

A porting of zio-optics to TypeScript
https://fp-ts.github.io/optic/
MIT License
113 stars 3 forks source link

Installation typo and TypeScript error in @fp-ts/optic README #42

Closed ninesunsabiu closed 1 year ago

ninesunsabiu commented 1 year ago

Thank you very much for the surprises brought to me by the fp-ts series, which has helped me grow a lot.
Now I'm trying to use @effect/* and @fp-ts/optic. However, I've found two issues in the README.md, and I hope to get some answers.

First, in the "Getting started" section, the installation method mentioned npm install @fp-ts/schema may be a typo, and the correct one should be npm install @fp-ts/optic.

Second, the example code in the "Summary" section will result in a TypeScript error, which is quite serious. Specifically, it shows:

image
Types of property 'getOptic' are incompatible.
        Type '(GetWhole: Employee) => Either<readonly [never, Employee], Option<string>>' is not assignable to type '(GetWhole: Employee) => Either<readonly [Error, Employee], Option<unknown>>'.ts(2769)

Here is minimal reproduction

However, I tried it in TypeScript playground and it works correctly.I am very confused.

image

Here is my environment:

ninesunsabiu commented 1 year ago

It seems like there's an incompatibility issue between the Option used in @effect/data, which is a dependency of @fp-ts/optic(^0.11.5), and the one used in my project's dependencies(^0.12.2).

image
gcanti commented 1 year ago

Yeah, the @effect/data dependency must be updated, working on it

gcanti commented 1 year ago

v0.8.0 released

ninesunsabiu commented 1 year ago

v0.8.0 released

Wow, that was really efficient! I was planning on having a meal before submitting a PR.