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

Custom groupBy return type incorrect #5

Open
ProfessorX737 opened this issue Jan 6, 2023 · 1 comment
Open

Custom groupBy return type incorrect #5

ProfessorX737 opened this issue Jan 6, 2023 · 1 comment

Comments

@ProfessorX737
Copy link

The custom groupBy return type should be Partial<Record<T[Key], T[]>>

@JRMurr
Copy link
Owner

JRMurr commented Jan 6, 2023

@ProfessorX737 ahh yea are you talking about the case for something like

const foo: Array<{type: 'a'} | {type: 'b'}> = [{type: 'a'}];

const grouped = groupBy(foo, 'type')

grouped.b //sad

I have actually ran into this after making that post and was able to work around it with https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy returning an empty array for all missing keys but it feels wrong

Ill update the post

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