Skip to content

fix: remove top-level properties when removeIfUndefined is set - #823

Open
Aminark wants to merge 2 commits into
react-component:masterfrom
Aminark:fix/remove-top-level-property
Open

Aminark wants to merge 2 commits into
react-component:masterfrom
Aminark:fix/remove-top-level-property

Conversation

@Aminark

@Aminark Aminark commented Oct 25, 2026 •

Copy link
Copy Markdown

set({ a: 1 }, ['a'], undefined, true) leaves an own property named a instead of deleting it. Nested paths already remove the property.

Handle the final path segment directly, including symbol keys and array entries. The added tests check that the source is unchanged and deleting an array entry keeps its length.

All 32 test suites pass (231 tests, 1 existing skip). The three new cases fail before the fix. TypeScript, changed-file lint, and the package build pass.

Summary by CodeRabbit

  • 错误修复
    • 使用 undefined 删除顶层属性时,目标对象会正确移除该属性,原对象保持不变。
    • 删除数组顶层索引时会留下空槽,数组长度及其他元素保持不变;原数组不受影响。

@vercel

vercel Bot commented Oct 25, 2026

Copy link
Copy Markdown

@Aminark is attempting to deploy a commit to the afc163's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 35c6353f-4934-472b-b054-00939aec9693
Commits

Reviewing files that changed from the base of the PR and between e12854b and d11ae9f.

Files selected for processing: 2
  • src/utils/set.ts
  • tests/utils.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

当 removeIfUndefined 为真且 value 为 undefined 时,internalSet 现在会在剩余路径为空时删除当前副本中的目标属性。新增测试覆盖对象属性和数组索引删除,并验证源对象或数组保持不变。

Changes

顶层属性删除

层 / 文件 摘要
空剩余路径的删除处理
src/utils/set.ts, tests/utils.test.ts
internalSet 在剩余路径为空时删除当前副本中的目标属性,并保留原有的末级路径删除逻辑。测试覆盖字符串键、Symbol 键和数组索引,并验证源对象或数组未改变。

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to d11ae

The change correctly removes requested properties while preserving the source object or array.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 标题准确概括了主要变更:当设置 removeIfUndefined 时,删除顶层属性。标题简洁、明确,并与代码和测试变更一致。
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

我是小兔,轻敲键盘忙,
字符属性悄悄离开场。
Symbol 键也能被删去,
数组留着空槽不摇晃。
原来的值仍安然无恙,
月光下我抱着胡萝卜欢唱。

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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.

1 participant