Skip to content

fix(compat/isMatchWith): align nested primitive matching with lodash in isMatchWith#1647

Open
D-Sketon wants to merge 2 commits intotoss:mainfrom
D-Sketon:fix/isMathWith
Open

fix(compat/isMatchWith): align nested primitive matching with lodash in isMatchWith#1647
D-Sketon wants to merge 2 commits intotoss:mainfrom
D-Sketon:fix/isMathWith

Conversation

@D-Sketon
Copy link
Copy Markdown
Contributor

Keep root-level primitive-vs-object behavior, but use strict equality for nested comparisons. This fixes false positives in matches/isMatch/isMatchWith.

Keep root-level primitive-vs-object behavior, but use strict equality for nested comparisons.
This fixes false positives in matches/isMatch/isMatchWith.
Copilot AI review requested due to automatic review settings March 15, 2026 16:00
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
es-toolkit Ready Ready Preview, Comment Apr 18, 2026 9:27am

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts the compat/predicate/isMatchWith implementation to better match Lodash behavior by preventing nested primitive-vs-object comparisons from returning false positives, while preserving the existing root-level behavior.

Changes:

  • Introduced an isRoot flag in isMatchWithInternal to distinguish root vs nested primitive matching semantics.
  • Updated recursion paths to pass isRoot appropriately (root call true, nested recursion false).
  • Added regression tests for matches, isMatch, and isMatchWith covering nested primitive-vs-object mismatches.

Reviewed changes

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

File Description
src/compat/predicate/isMatchWith.ts Adds root-awareness to internal matching so nested primitive/object mismatches use strict equality.
src/compat/predicate/matches.spec.ts Adds regression test for nested primitive source vs object target mismatch.
src/compat/predicate/isMatch.spec.ts Adds regression test ensuring isMatch no longer returns a false positive for nested primitive/object mismatch.
src/compat/predicate/isMatchWith.spec.ts Adds regression test for isMatchWith nested primitive/object mismatch when customizer yields undefined.

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

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

Successfully merging this pull request may close these issues.

2 participants