Skip to content

fix: preserve branded primitive values - #810

Open
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/preserve-branded-values
Open

fix: preserve branded primitive values#810
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/preserve-branded-values

Conversation

@nrps9909

@nrps9909 nrps9909 commented Aug 28, 2026

Copy link
Copy Markdown

Summary\n\n- treat primitive values as RecursivePartial leaf types\n- preserve branded and nominal string, number, bigint, boolean, and symbol values\n- add a compile-time regression for a branded domain ID\n\n## Problem\n\nRecursivePartial currently checks the object branch before recognizing branded primitives. A branded string therefore gets recursively mapped over its object-like keys instead of remaining the original domain type. This is the behavior reported in #390 and it still reproduces with the current TypeScript 6 toolchain.\n\nThe new type assertion fails on the exact base with Type true is not assignable to type false, then passes when primitives are retained as leaves. Object, array, readonly array, Date, RegExp, Function, Map, and Set behavior is unchanged.\n\nFixes #390.\n\n## Verification\n\n- exact-base type regression reproduced\n- TypeScript no-emit check passed\n- focused type-check suite: 4/4 tests passed\n- full suite: 24/24 suites, 203 passed and 1 skipped\n- ESM, CJS, and declaration build passed\n- ESLint has zero errors and only existing unused-disable warnings\n- Prettier and diff checks passed\n\nAI assistance disclosure: Codex helped construct the type-level reproduction, trace the conditional type behavior, implement the scoped guard, and run verification.

Summary by CodeRabbit

  • 改进

    • 优化递归类型处理,原始类型现在会直接保留,不再递归处理其属性。
    • 改进复杂类型的部分类型推导,提升类型检查的准确性。
  • 测试

    • 新增类型等价性测试,验证带唯一标记的领域类型及其递归部分类型能够正确推导。

@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

@nrps9909 is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 048bc27b-bcbb-43bf-aef0-24ed1cda5364

📥 Commits

Reviewing files that changed from the base of the PR and between 2452b54 and 8ee3365.

📒 Files selected for processing (2)
  • src/interface.ts
  • tests/nameTypeCheck.test.tsx

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


Walkthrough

本次变更更新 RecursivePartial 的原始类型处理,并新增 DomainId 品牌类型的编译期测试,确保递归部分保留品牌类型。

Changes

RecursivePartial 类型修复

Layer / File(s) Summary
新增原始类型终止判断
src/interface.ts
新增 Primitive 类型别名。RecursivePartial 对原始类型直接返回原类型。
验证品牌类型递归部分
tests/nameTypeCheck.test.tsx
新增类型等价性辅助类型、DomainIdBrandedPartial。测试验证 id 的类型为 DomainId | undefined

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

Merge Risk: ⚪ Minimal · up to 8ee33

The PR preserves branded primitive types without changing runtime form behavior or deployment characteristics. No actionable merge-blocking risk remains after normal checks and review.

Poem

小兔敲键盘,类型不再迷路
Primitive 守在递归尽头
DomainId 保留自己的印记
Partial 轻轻展开属性
编译器点头,测试通过啦

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题“fix: preserve branded primitive values”准确概括了主要变更,内容具体且简洁。
Linked Issues check ✅ Passed 代码将原始类型加入 RecursivePartial 的终止类型判断,并增加 DomainId 编译期回归测试。该实现满足问题 #390 关于保留 branded primitive 类型的要求。
Out of Scope Changes check ✅ Passed 变更仅涉及 RecursivePartial 类型定义和对应的类型测试。未发现与问题 #390 无关的代码变更。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.54%. Comparing base (2452b54) to head (8ee3365).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #810   +/-   ##
=======================================
  Coverage   99.54%   99.54%           
=======================================
  Files          20       20           
  Lines        1329     1329           
  Branches      309      309           
=======================================
  Hits         1323     1323           
  Misses          6        6           

☔ 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.

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