typed-typings / npm-ramda

TypeScript's type definitions for Ramda
MIT License
384 stars 64 forks source link

Generics lost on currying for higher-order functions #440

Open tgelu opened 5 years ago

tgelu commented 5 years ago

@tycho01 has closed #78 which was very related to this.

I have the following silly array map

let map = <A, B>(f: (x: A) => B, ar: Array<A>) : Array<B> =>{
  let next = ar.pop()
  return typeof next !== 'undefined' ? [f(next)].concat(map(f, ar)) : []
}

let cmap = curry(map)

This works just fine until I curry it. Then, no matter how I call it typescript won't compile it with the following error:

error TS2365: Operator '+' cannot be applied to types '{}' and '5'.
cmap(x => x + 5)([1, 2, 3])

Not even when I tell it that x is a number.

KiaraGrouwstra commented 5 years ago

hm. I think there were issues on losing generics at the TS repo but can't recall which. I think the DT types for ramda have been catching up if not out-pacing this repo though. maybe try if those work better for you?