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

Curried map #171

Closed
Ramblurr opened this issue Apr 25, 2017 · 2 comments
Closed

Curried map #171

Ramblurr opened this issue Apr 25, 2017 · 2 comments

Comments

@Ramblurr
Copy link

Using the curried map with an Array doesn't work.

Example: doesn't compile

function testMap() {
  const data = [
    {id: 1, name: "Alice"},
    {id: 2, name: "Bob"},
  ];
  const nameProp = R.prop("name");
  const nameMap = R.map(nameProp);
  const names: string[] = nameMap(data); // error here
  
  // expected => ["Alice", "Bob"]
}

Instead the TS error is:

TS2322:Type 'Functor' is not assignable to type 'string[]'. Property 'includes' is missing in type 'Functor'.

This is the type def for the one-parameter map:

        // object

        // mixed:
        map<T, U>(fn: (x: T) => U): {
          <M extends Obj<T>>(obj: M): Obj<U>;
          <K extends string>(obj: Obj<T>): Obj<U>;
          (obj: Functor<T>): Functor<U>;
          (list: T[]): U[];
        };
@KiaraGrouwstra
Copy link
Member

Thanks for filing this, I remember bumping into it as well. I'd yet to figure it out though. That said, I'd wonder if this is an order thing (maybe the array version should come above functor)?

@KiaraGrouwstra
Copy link
Member

Should be fixed with the refactor from #190

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