Skip to content

type into in typescript #441

@codingedgar

Description

@codingedgar

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions