fix(drop,filter,groupBy,indexBy,isEmptyish,mapKeys,omit,pick,prop,sample,...): Remove trivial type-fest utilities#1366
Conversation
|
|
✅ Deploy Preview for trusting-lumiere-9c7fad ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
commit: |
There was a problem hiding this comment.
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/OrandAndand 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.
Or and And|
🎉 This PR is included in version 2.38.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |

There are perf issues with importing
OrandAndfrom 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%).