Skip to content

fix(map, mapWithFeedback): Correct types through NoInfer#1368

Merged
eranhirsch merged 3 commits into
mainfrom
worktree-issue-1364
Jun 9, 2026
Merged

fix(map, mapWithFeedback): Correct types through NoInfer#1368
eranhirsch merged 3 commits into
mainfrom
worktree-issue-1364

Conversation

@eranhirsch

Copy link
Copy Markdown
Member

Fixes: #1364

When an array is typed through a NoInfer (as in the attached issue) it fails to map properly via mapped types (while still being inferred as an array). To work around this we short-circuit our mapped type for simple arrays.

Copilot AI review requested due to automatic review settings June 9, 2026 12:18
@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 9, 2026

Copy link
Copy Markdown

Deploy Preview for trusting-lumiere-9c7fad ready!

Name Link
🔨 Latest commit e246562
🔍 Latest deploy log https://app.netlify.com/projects/trusting-lumiere-9c7fad/deploys/6a28076dc78e230008f8428e
😎 Deploy Preview https://deploy-preview-1368--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 9, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1368   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          175       175           
  Lines         1648      1648           
  Branches       405       405           
=========================================
  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 9, 2026

Copy link
Copy Markdown

commit: e246562

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 adjusts the internal Mapped<T, K> type used by map/mapWithFeedback to avoid a TypeScript inference edge case where arrays flowing through NoInfer<T> stop behaving like normal arrays in downstream generic constraints (e.g. sortBy), while preserving tuple “shape” behavior.

Changes:

  • Update Mapped<T, K> to short-circuit to K[] when T is effectively a “simple array” (T[number][] extends T), avoiding a broken mapped-type result in NoInfer scenarios.
  • Add type-level regression tests for map around empty/optional tuples and the NoInfersortBy pipeline case.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/remeda/src/map.test-d.ts Adds type regression coverage for empty/optional tuples and the NoInfer inference issue flowing into sortBy (including pipe/data-last).
packages/remeda/src/internal/types/Mapped.ts Changes Mapped to fall back to K[] for simple arrays to avoid TypeScript mapped-type inference failures with NoInfer.

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

Comment thread packages/remeda/src/internal/types/Mapped.ts
@eranhirsch eranhirsch merged commit 53d22a6 into main Jun 9, 2026
39 checks passed
@eranhirsch eranhirsch deleted the worktree-issue-1364 branch June 9, 2026 12:34
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 2.39.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.

map: Data-last sortBy in pipe infers single element type instead of array when input type flows through NoInfer

2 participants