Closed cowboyd closed 2 years ago
Oooh very interesting. I haven't tested this with 3.7 or above, I'll try to carve some time and investigate. Handling possibly undefined values has been a real bear for this library.
This is resolved in later versions of TS; I'm publishing shades@2.2 later today which will update all dependencies.
Hello,
Thank you for the great library and the thoughtful README. This api is very user-friendly.
I'm evaluating shades as a replacement for ramda lenses since we're having a devil of a time with Ramda lenses and TS. Shades looks like it's got a lot of promise in this direction, so we're very interested in seeing how it will work.
I ran into a stumbling block pretty early on when composing lenses with the
get
method. TypeScript thinks thatget('user', 'username')
is a function that returnsundefined
. Specifically<S extends HasKey<"user", HasKey<"username", any>>>(s: S) => undefined
The
get
itself works, but you can't actually use any values produced by it in TypeScript because the compiler thinks it'sundefined
and therefore unsafe.Here are some screenshots showing the errors:
Here is the repo I'm using https://github.com/cowboyd/shades-test