Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Generics lost on currying for higher-order functions #440

Open
tgelu opened this issue Jul 11, 2019 · 1 comment
Open

Generics lost on currying for higher-order functions #440

tgelu opened this issue Jul 11, 2019 · 1 comment

Comments

@tgelu
Copy link

tgelu commented Jul 11, 2019

@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
Copy link
Member

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?

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

No branches or pull requests

2 participants