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

Issue with find: doesn't flow #88

Closed
wclr opened this issue Aug 31, 2016 · 4 comments
Closed

Issue with find: doesn't flow #88

wclr opened this issue Aug 31, 2016 · 4 comments

Comments

@wclr
Copy link
Contributor

wclr commented Aug 31, 2016

type Task = {id: number}
let tasks: Task[] = []
R.find(task => task.id === 1, tasks) // this works

R.find(task => task.id === 1)(tasks) // this doesn't work works

Is it possible to make it flow in second case?

@wclr
Copy link
Contributor Author

wclr commented Aug 31, 2016

The same problem actually with other methods:

let obj: { id: number } = { id: 1 }
R.prop<string>('id')(obj)

And in general I believe that is some limitation of TS. In this cases it is more appropriate to use not ramda but simple mapping function like (_) => _.id that will flow perfectly.

Ok this will flow:

let obj: { id: number } = { id: 1 }
R.prop('id')<string>(obj)

But how to use it with for example R.compose to get correct flow?

let obj: { id: number } = { id: 1 }
R.compose(R.prop('id')<string>)(obj) // this won't work

What do you think?

@donnut
Copy link
Collaborator

donnut commented Sep 2, 2016

I changed the definition of the curried find to:
find<T>(fn: (a: T) => boolean): <T>(list: T[]) => T;
and now it works as expected, see pr #91

@donnut
Copy link
Collaborator

donnut commented Sep 2, 2016

Concerning the 'prop'-issue. This is a know limitiation of TS. Version 1.8+ should fix that, see #10

@donnut donnut closed this as completed Sep 2, 2016
@wclr
Copy link
Contributor Author

wclr commented Sep 2, 2016

@donnut

Concerning the 'prop'-issue. This is a know limitiation of TS. Version 1.8+ should fix that, see #10

I'm using 2.1-dev. What signature are you talking about? It seem that string based typing is not supported.

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