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

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

Open
michaelwittwer opened this issue May 7, 2024 · 0 comments
Open
Assignees
Labels
bug Something isn't working pkg: utilities

Comments

@michaelwittwer
Copy link
Member

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 */) 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg: utilities
Projects
None yet
Development

No branches or pull requests

2 participants