Skip to content

[lodash] Unable to map over a partition in a chain #46377

@danvk

Description

@danvk
interface Person {
  name: string;
  age: number;
}

declare let people: Person[];
const [evens, odds] = _(people)
  .partition(p => p.age % 2 === 0)
  .map(parityPeople => parityPeople.map(p => p.name))
// ~~~ Property 'map' does not exist on type 'LoDashImplicitWrapper<[Person[], Person[]]>'.
  .value();

This code runs fine but fails to type check. Mapping over an unwrapped tuple type using the native map is fine:

  const [evens, odds] = _(people)
    .partition(p => p.age % 2 === 0)
    .value()
    .map(parityPeople => parityPeople.map(p => p.name));  // ok

If you do not mention the authors the issue will be ignored.

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