I'm using monocle-ts (https://github.com/gcanti/monocle-ts) library in my project. I have the following code
import {id, prop} from 'monocle-ts/lib/Lens'
import {pipe} from 'fp-ts/function'
type State = {a: string, b: string}
const stateLens = id<State>()
const aLens = pipe(stateLens, prop('a'))
^ this code works perfectly fine, type system will not allow me to pass string that is not either 'a' or 'b'. However if I'm trying to write the same code in other way:
const aLens = prop('a')(stateLens)
I'm getting an error: Argument of type 'string' is not assignable to parameter of type 'never'
Type definitions of prop
function looks like this:
declare const prop: <A, P extends keyof A>(prop: P) => <S>(sa: Lens<S, A>) => Lens<S, A[P]>
I'm guessing that by using pipe-style typescript is somehow able to infer all generic parameters which is not the case for regular prop(...)(...)
invocation