Skip to content

Conversation

@edison1105
Copy link
Member

@edison1105 edison1105 commented Nov 6, 2025

close #14056

Summary by CodeRabbit

  • Tests

    • Added test coverage verifying type behavior when a prop is declared as never, ensuring regressions are caught.
  • Bug Fixes

    • Improved TypeScript inference for optional boolean props used with defineProps, providing stricter and more accurate editor hints and fewer incorrect type widenings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 6, 2025

Walkthrough

Refines a conditional type used to detect boolean-like prop keys and adds a type test ensuring props declared as never are handled correctly by defineProps.

Changes

Cohort / File(s) Change Summary
Test additions
packages-private/dts-test/setupHelpers.test-d.ts
Adds a new test block "defineProps w/ never prop" asserting foo?: never yields `never
Type narrowing
packages/runtime-core/src/apiSetupHelpers.ts
Changes BooleanKey<T> conditional to further check `T[K] extends boolean

Sequence Diagram(s)

sequenceDiagram
    participant Dev as defineProps call site
    participant BooleanKey as BooleanKey<T>
    participant TS as TypeScript resolver

    Note over Dev,TS: Type selection for each prop key
    Dev->>BooleanKey: provide prop type T[K]
    BooleanKey->>TS: evaluate "T[K] extends boolean | undefined?"
    TS-->>BooleanKey: yes/no
    alt matches boolean|undefined
        BooleanKey->>TS: evaluate "T[K] extends never | undefined?"
        TS-->>BooleanKey: yes -> exclude key
        TS-->>BooleanKey: no  -> include key
    else does not match
        BooleanKey-->>Dev: exclude key
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Key areas for attention:
    • Correctness of the nested conditional type in BooleanKey<T> (verify behavior with never, optional, and unions like boolean | undefined/boolean | null)
    • The new test covers the reported edge case; consider additional tests for required booleans and boolean unions
    • Confirm no unintended regressions in other type branches that rely on BooleanKey

Suggested reviewers

  • KazariEX
  • johnsoncodehk

Poem

🐰 A hop of types beneath the moonlit test,
Never hid from props — now checked and dressed.
Boolean keys pruned clean with gentle cheer,
The rabbit stamps approval — types are clear!

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: fixing a typing issue where never props incorrectly become boolean flags in defineProps.
Linked Issues check ✅ Passed The PR addresses the core issue (#14056) by refining the BooleanKey type to exclude never props from being treated as boolean flags, which directly resolves the reported typing problem.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the reported issue: a type refinement in apiSetupHelpers.ts and a corresponding test in the test file.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch edison/fix/14056

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0600862 and 6079bdb.

📒 Files selected for processing (1)
  • packages/runtime-core/src/apiSetupHelpers.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/runtime-core/src/apiSetupHelpers.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Redirect rules
  • GitHub Check: Header rules
  • GitHub Check: Pages changed

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

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 103 kB 38.9 kB 35 kB
vue.global.prod.js 161 kB 58.8 kB 52.4 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 46.9 kB 18.3 kB 16.8 kB
createApp 55 kB 21.4 kB 19.6 kB
createSSRApp 59.3 kB 23.1 kB 21.1 kB
defineCustomElement 60.6 kB 23.1 kB 21.1 kB
overall 69.3 kB 26.6 kB 24.3 kB

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 6, 2025

Open in StackBlitz

@vue/compiler-core

npm i https://pkg.pr.new/@vue/compiler-core@14059

@vue/compiler-dom

npm i https://pkg.pr.new/@vue/compiler-dom@14059

@vue/compiler-sfc

npm i https://pkg.pr.new/@vue/compiler-sfc@14059

@vue/compiler-ssr

npm i https://pkg.pr.new/@vue/compiler-ssr@14059

@vue/reactivity

npm i https://pkg.pr.new/@vue/reactivity@14059

@vue/runtime-core

npm i https://pkg.pr.new/@vue/runtime-core@14059

@vue/runtime-dom

npm i https://pkg.pr.new/@vue/runtime-dom@14059

@vue/server-renderer

npm i https://pkg.pr.new/@vue/server-renderer@14059

@vue/shared

npm i https://pkg.pr.new/@vue/shared@14059

vue

npm i https://pkg.pr.new/vue@14059

@vue/compat

npm i https://pkg.pr.new/@vue/compat@14059

commit: 6079bdb

@edison1105 edison1105 requested a review from KazariEX November 6, 2025 03:53
@edison1105 edison1105 added scope: types ready to merge The PR is ready to be merged. labels Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to merge The PR is ready to be merged. scope: types

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeScript enables strict mode, and the interface includes an optional never type; defineProps returns the never type.

3 participants