Skip to content

[utilities] change return of groupBy to be Partial<Record<...>> #27

@michaelwittwer

Description

@michaelwittwer

The current return type of groupBy is Record<string, T[]> which is not true. For example:

const entries = [{
  projectId: 52893075,
  description: "My description",
  isDuplicate: true
}]

const grouped = groupBy(entries, (e) => e.isDuplicate ? 1 : 0)
/*
 * ❗grouped[0] is undefined in runtime, but typescript does not complain. groupBy does not initialize empty arrays for non existing 
 * keys in given collection
 */
grouped[0].map(/* missing impl */) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions