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

type into in typescript #441

Open
codingedgar opened this issue Jul 23, 2019 · 0 comments
Open

type into in typescript #441

codingedgar opened this issue Jul 23, 2019 · 0 comments

Comments

@codingedgar
Copy link

Hi!
first, thank you all for this superb library!

I loooove transducers, so i'm usually using transducer or into everywhere i can, but in typescript land, it has been very hard for me to type it, i would like to understand both how could type it and if it is not possible where is the issue.


import {
  filter,
  into,
  map,
  compose,
} from 'ramda';

type OrderAndValue = { order: number, value: string }

type Values = string[]

const vals: Values = into<any>(
  [],
  compose<any, any, any>(
    filter<any>(x => x.id > 5),
    map<any, any>(x => x.val)
  ),
  [
    { order: 1, value: 'a' },
    { order: 5, value: 'b' },
    { order: 10, value: 'c' },
  ]
)

here, for typescript is so difficult to understand what gets into map, because transducer expects to apply the fns in compose in the read order.

My question: is there any way to type this ? to get the type of OrderAndValue in the map and return Values ?

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

1 participant