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

Currying and TypeScript #548

Closed
ivan-kleshnin opened this issue Sep 18, 2020 · 4 comments
Closed

Currying and TypeScript #548

ivan-kleshnin opened this issue Sep 18, 2020 · 4 comments

Comments

@ivan-kleshnin
Copy link
Contributor

I'm a Typescript newbie... As it seems, R.curry function does not preserve typing at all (returning any). I suppose this is due to TypeScript limitations on generics and variadic args. Would be great if you enlighten us on the current status quo of this topic.

Looks like TypeScript 4 has all the ingredients for generic curry. Are you going to update as it leaves beta?

Are there some workarounds to make curried and strictly typed functions (with or without R.curry) right now?

@selfrefactor
Copy link
Owner

selfrefactor commented Sep 19, 2020

Unfortunately, there is nothing much to share. I was subscribed to variadic functions Typescript issue so I have the change to play very early on with variadic tuple types. I also read all the discussions and examples around it in the hope that I will be able to use it in Rambda. As much as I tried, I couldn't make it work. I have the impression that this feature alone is not enough and further features are needed in order to receive proper R.curry/R.compose definitions.

Now, there is not much I can do, so I am just hoping that maintainers of @types/ramda to take advantage of this new TS feature. Other option is to open a Stackoverflow question. I will provide a link to it, once I open it.

@ivan-kleshnin
Copy link
Contributor Author

ivan-kleshnin commented Sep 21, 2020

Ok, I got the situtation, thanks for sharing!

I discovered, for myself, that I'm fine with (x: a) => (y: b) : c kind of typings. They are a piece of cake to type comparing to variadic and while they require to call functions like fn(x)(y) instead of fn(x, y) that is such a minor detail in overall picture so it's probably not worth fighting against. A significant % of functions I write are composed with R.pipe anyway so I don't see a difference.

Guys from https://github.com/sanctuary-js/sanctuary came to the same conclusion and now I certainly see how.

@selfrefactor
Copy link
Owner

I, myself barely use R.curry, so you have deeper insights what typings works best.
So, you don't mind the current R.curry typings? If so, then you wouldn't mind closing this issue, as I promise to update R.curry once @types/ramda make any change to it.

@ivan-kleshnin
Copy link
Contributor Author

ivan-kleshnin commented Sep 21, 2020

Sure, I don't mind, I only wanted to ask your opinion.
Thanks again, wish you a productive week!

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