Skip to content

fix(types): prevent shallowReactive marker from leaking into value unions#14493

Open
edison1105 wants to merge 1 commit intomainfrom
edison/fix/14490
Open

fix(types): prevent shallowReactive marker from leaking into value unions#14493
edison1105 wants to merge 1 commit intomainfrom
edison/fix/14490

Conversation

@edison1105
Copy link
Member

@edison1105 edison1105 commented Feb 28, 2026

close #14490

Summary by CodeRabbit

  • Bug Fixes
    • Corrected type behavior for shallow reactive objects to properly handle marker propagation in type unions.

@coderabbitai
Copy link

coderabbitai bot commented Feb 28, 2026

📝 Walkthrough

Walkthrough

Fixes a TypeScript typing issue where the ShallowReactive marker was leaking into union types, causing incorrect type errors. The marker type is changed from an optional boolean to a required never property, with corresponding unwrapping logic updates to correctly handle the new signature.

Changes

Cohort / File(s) Summary
ShallowReactive Type Signature
packages/reactivity/src/reactive.ts
Changed ShallowReactive marker from optional boolean ([ShallowReactiveMarker]?: true) to required never ([ShallowReactiveMarker]: never) to prevent marker leakage into value unions.
Type Unwrapping Logic
packages/reactivity/src/ref.ts
Updated UnwrapRefSimple type branching to match the new required marker property, adjusting when shallow reactive objects short-circuit unwrapping versus proceeding through general object unwrapping paths.
Test Coverage
packages-private/dts-test/reactivity.test-d.ts
Added test case verifying that the ShallowReactive marker does not leak into value unions, confirming correct type narrowing for properties in shallow reactive objects.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • vuejs/core#12420: Modifies the same ref/unwrapping type-level logic for shallowReactive in packages/reactivity (ref.ts/reactive.ts).

Suggested labels

ready to merge, scope: reactivity, :hammer: p3-minor-bug

Poem

🐰 A marker once hid in the union's dark fold,
Making types misbehave, oh what a scold!
But clever word "never" set things right,
Now shallowReactive glows pure and bright! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The pull request addresses the core issue #14490 by changing ShallowReactiveMarker from optional true to required never, preventing the marker from leaking into v-for type inference for shallowReactive objects.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the shallowReactive typing issue: marker type definition, UnwrapRefSimple logic, and a test case validating the fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title 'prevent shallowReactive marker from leaking into value unions' directly and clearly summarizes the main change across the PR: modifying the ShallowReactive marker from optional to required to prevent it from appearing in union types during iteration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch edison/fix/14490

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

@github-actions
Copy link

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 104 kB 39.3 kB 35.4 kB
vue.global.prod.js 162 kB 59.3 kB 52.8 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 47.8 kB 18.6 kB 17.1 kB
createApp 56 kB 21.7 kB 19.8 kB
createSSRApp 60.2 kB 23.4 kB 21.4 kB
defineCustomElement 61.6 kB 23.4 kB 21.4 kB
overall 70.4 kB 27 kB 24.6 kB

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 28, 2026

Open in StackBlitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@14493
npm i https://pkg.pr.new/@vue/compiler-core@14493
yarn add https://pkg.pr.new/@vue/compiler-core@14493.tgz

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@14493
npm i https://pkg.pr.new/@vue/compiler-dom@14493
yarn add https://pkg.pr.new/@vue/compiler-dom@14493.tgz

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@14493
npm i https://pkg.pr.new/@vue/compiler-sfc@14493
yarn add https://pkg.pr.new/@vue/compiler-sfc@14493.tgz

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@14493
npm i https://pkg.pr.new/@vue/compiler-ssr@14493
yarn add https://pkg.pr.new/@vue/compiler-ssr@14493.tgz

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@14493
npm i https://pkg.pr.new/@vue/reactivity@14493
yarn add https://pkg.pr.new/@vue/reactivity@14493.tgz

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@14493
npm i https://pkg.pr.new/@vue/runtime-core@14493
yarn add https://pkg.pr.new/@vue/runtime-core@14493.tgz

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@14493
npm i https://pkg.pr.new/@vue/runtime-dom@14493
yarn add https://pkg.pr.new/@vue/runtime-dom@14493.tgz

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@14493
npm i https://pkg.pr.new/@vue/server-renderer@14493
yarn add https://pkg.pr.new/@vue/server-renderer@14493.tgz

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@14493
npm i https://pkg.pr.new/@vue/shared@14493
yarn add https://pkg.pr.new/@vue/shared@14493.tgz

vue

pnpm add https://pkg.pr.new/vue@14493
npm i https://pkg.pr.new/vue@14493
yarn add https://pkg.pr.new/vue@14493.tgz

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@14493
npm i https://pkg.pr.new/@vue/compat@14493
yarn add https://pkg.pr.new/@vue/compat@14493.tgz

commit: 7c14ef3

@edison1105 edison1105 changed the title fix(types): exclude symbol keys from renderList object value inference fix(types): prevent shallowReactive marker from leaking into value unions Feb 28, 2026
@edison1105
Copy link
Member Author

/ecosystem-ci run

@vue-bot
Copy link
Contributor

vue-bot commented Feb 28, 2026

📝 Ran ecosystem CI: Open

suite result latest scheduled
quasar success success
pinia success success
language-tools success success
radix-vue success success
router success success
nuxt success success
test-utils success success
vant success success
primevue success success
vuetify failure success
vite-plugin-vue success success
vue-macros success success
vitepress success success
vue-i18n success success
vueuse success success
vue-simple-compiler success success

@edison1105
Copy link
Member Author

/ecosystem-ci run vuetify

@vue-bot
Copy link
Contributor

vue-bot commented Feb 28, 2026

📝 Ran ecosystem CI: Open

suite result latest scheduled
vuetify failure success

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shallowReactive with v-for incorrect typing: property does not exist on type true

2 participants