Skip to content

Conversation

@JonasBa
Copy link
Member

@JonasBa JonasBa commented Nov 18, 2025

Spreading when we iterate over each item will cause quadratic runtime as the accumulator object is iterated for each item.

@JonasBa JonasBa requested review from TkDodo and gggritso November 18, 2025 19:08
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Nov 18, 2025
@JonasBa JonasBa merged commit db19982 into master Nov 18, 2025
48 checks passed
@JonasBa JonasBa deleted the jb/groupstore/reduce-complexity branch November 18, 2025 22:47
@scefali
Copy link
Contributor

scefali commented Nov 19, 2025

Nice

@TkDodo TkDodo mentioned this pull request Nov 19, 2025
Comment on lines +153 to +157
const itemsById: Record<string, Item> = items.reduce((acc, item) => {
// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
acc[item.id] = item;
return acc;
}, {});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick follow up:

we don’t need the ts-expect-error if we “type” reduce itself

TkDodo added a commit that referenced this pull request Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants