Skip to content

fix(drop,filter,groupBy,indexBy,isEmptyish,mapKeys,omit,pick,prop,sample,...): Remove trivial type-fest utilities#1366

Merged
eranhirsch merged 14 commits into
mainfrom
eranhirsch/tsOrAndPerf
Jun 7, 2026
Merged

fix(drop,filter,groupBy,indexBy,isEmptyish,mapKeys,omit,pick,prop,sample,...): Remove trivial type-fest utilities#1366
eranhirsch merged 14 commits into
mainfrom
eranhirsch/tsOrAndPerf

Conversation

@eranhirsch

@eranhirsch eranhirsch commented Jun 6, 2026

Copy link
Copy Markdown
Member

There are perf issues with importing Or and And from type-fest which drag our types down. Additionally, the utility idiom doesn't jive well with TypeScript because it prevents it from narrowing branches correctly. This means we lose both a layer of type safety and pay it with perf all for a bit of readability.

Some perf wins (percent reduction of instantiation time), mainly due to wins in TupleParts: isEmptyish (88%), filter (84%), swapIndices (83%), drop (75%), partialBind (74%), partialLastBind (72%), sample (68%), mergeAll (62%), truncate (52%), mapKeys (3%), pick (3%), omit (3%), pickBy (3%), omitBy (3%), hasProp (3%), groupBy (3%), groupByProp (3%), countBy (3%), indexBy (3%), pullObject (3%), fromKeys (3%).

Copilot AI review requested due to automatic review settings June 6, 2026 09:05
@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@netlify

netlify Bot commented Jun 6, 2026

Copy link
Copy Markdown

Deploy Preview for trusting-lumiere-9c7fad ready!

Name Link
🔨 Latest commit e7759f9
🔍 Latest deploy log https://app.netlify.com/projects/trusting-lumiere-9c7fad/deploys/6a258e10ea8c1b0008686937
😎 Deploy Preview https://deploy-preview-1366--trusting-lumiere-9c7fad.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (0650fd7) to head (e7759f9).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1366   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          175       175           
  Lines         1648      1648           
  Branches       405       396    -9     
=========================================
  Hits          1648      1648           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new

pkg-pr-new Bot commented Jun 6, 2026

Copy link
Copy Markdown

commit: e7759f9

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR replaces type-fest’s boolean combinator types (Or/And) with lightweight local equivalents to reduce TypeScript type-instantiation overhead, especially in hot types like TupleParts that impact many array utilities.

Changes:

  • Introduce local src/internal/types/Or and And and switch affected utilities to the tuple-operands form (Or<[...]>, And<[...]>).
  • Update several type-level utilities (TupleParts, IsBounded, ArrayRequiredPrefix, etc.) to use the new combinators.
  • Add type tests for the new combinators and minor repo hygiene updates (.gitignore, skill docs).

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/remeda/src/truncate.ts Swap type-fest And for local And and update callsite to tuple operands.
packages/remeda/src/swapIndices.ts Swap type-fest And for local And and update type guards to tuple operands.
packages/remeda/src/sample.ts Swap type-fest Or for local Or and update to tuple operands.
packages/remeda/src/randomInteger.ts Swap type-fest Or for local Or and update to tuple operands.
packages/remeda/src/omitBy.ts Swap type-fest Or for local Or and update to tuple operands.
packages/remeda/src/mapKeys.ts Swap type-fest And/Or for local equivalents and update to tuple operands.
packages/remeda/src/isEmptyish.ts Swap type-fest And/Or for local equivalents and update to tuple operands.
packages/remeda/src/internal/types/TupleParts.ts Use local Or and update recursion stop condition to tuple operands.
packages/remeda/src/internal/types/Or.ts Add new local Or combinator type.
packages/remeda/src/internal/types/Or.test-d.ts Add type tests for local Or.
packages/remeda/src/internal/types/IsBounded.ts Use local Or and update operands form.
packages/remeda/src/internal/types/ArrayRequiredPrefix.ts Use local And and update operands form.
packages/remeda/src/internal/types/And.ts Add new local And combinator type.
packages/remeda/src/internal/types/And.test-d.ts Add type tests for local And.
packages/remeda/src/groupByProp.ts Swap type-fest Or for local Or and update operands form.
.gitignore Ignore .tmp/ and .playwright-mcp/.
.agents/skills/remeda-utility/reference/implementation.md Document rationale and guidance for TupleParts and boolean combinator performance.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/remeda/src/internal/types/Or.ts Outdated
Comment thread packages/remeda/src/internal/types/And.ts Outdated
Comment thread packages/remeda/src/internal/types/Or.test-d.ts Outdated
Comment thread packages/remeda/src/internal/types/And.test-d.ts Outdated
@eranhirsch eranhirsch changed the title fix: Replace type-fest Or and And fix: Remove trivial type-fest utilities Jun 6, 2026
@eranhirsch eranhirsch changed the title fix: Remove trivial type-fest utilities fix(typescript-perf): Remove trivial type-fest utilities Jun 6, 2026
@eranhirsch eranhirsch changed the title fix(typescript-perf): Remove trivial type-fest utilities fix(chunk,drop,filter,groupBy,mapKeys,omit,pick,prop,sample,...): Remove trivial type-fest utilities Jun 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 20 changed files in this pull request and generated no new comments.

@eranhirsch eranhirsch changed the title fix(chunk,drop,filter,groupBy,mapKeys,omit,pick,prop,sample,...): Remove trivial type-fest utilities fix(drop,filter,groupBy,mapKeys,omit,pick,prop,sample,...): Remove trivial type-fest utilities Jun 7, 2026
@eranhirsch eranhirsch changed the title fix(drop,filter,groupBy,mapKeys,omit,pick,prop,sample,...): Remove trivial type-fest utilities fix(drop,filter,groupBy,indexBy,isEmptyish,mapKeys,omit,pick,prop,sample,...): Remove trivial type-fest utilities Jun 7, 2026
@eranhirsch eranhirsch merged commit c8a7c2b into main Jun 7, 2026
43 checks passed
@eranhirsch eranhirsch deleted the eranhirsch/tsOrAndPerf branch June 7, 2026 15:44
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 2.38.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants