Skip to content

Conversation

edison1105
Copy link
Member

@edison1105 edison1105 commented Sep 19, 2025

Playground

Summary by CodeRabbit

  • New Features

    • Support ignoring runtime type inference for props annotated with @vue-ignore, ensuring those props resolve to an unknown type at runtime.
  • Bug Fixes

    • Align behavior across inference paths so @vue-ignore consistently prevents runtime type inference, avoiding unintended prop type resolutions.
  • Tests

    • Added coverage to verify that properties marked with @vue-ignore are treated as unknown during prop resolution.

Copy link

coderabbitai bot commented Sep 19, 2025

Walkthrough

Adds an ignore pre-check in runtime type inference to return Unknown when a node has a leading "@vue-ignore" comment, and extends tests with a case covering TypeScript property signatures using the ignore marker. No public APIs changed.

Changes

Cohort / File(s) Summary
Runtime type resolution logic
packages/compiler-sfc/src/script/resolveType.ts
Added a leading-comment check for "@vue-ignore" in inferRuntimeType, returning [UNKNOWN_TYPE] early for annotated nodes. Control flow now bypasses inference for ignored nodes.
Test coverage
packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts
Added test "TSPropertySignature with ignore" validating that /* @vue-ignore */ on a property type results in Unknown for that prop in defineProps.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant TS as TS Node
  participant RT as inferRuntimeType
  participant R as Resolver

  Note over TS,RT: Node may have a leading comment

  RT->>TS: Inspect leading comments
  alt Has "@vue-ignore"
    RT-->>R: Return [UNKNOWN_TYPE] (skip inference)
  else No ignore
    RT->>R: Proceed with normal type inference
    R-->>RT: Inferred runtime type(s)
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I nibbled through types with curious care,
Found a whisper: “vue-ignore” in the air.
Hop! I skip the thicket, Unknown I declare—
Tests now wink, “we saw you there.”
Ears up, code neat, carrots to spare! 🥕✨

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title is a concise, single-sentence conventional-commit style summary that directly describes the primary change: adding support for @vue-ignore in runtime type resolution within the compiler-sfc package. It matches the changes in the diff (runtime inference gate plus test) and is specific enough for a quick scan of PR history.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch edison/fix/vueIgnoreWithInferRuntimeType

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

Copy link

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 101 kB 38.5 kB 34.6 kB
vue.global.prod.js 159 kB 58.6 kB 52.1 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 46.6 kB 18.2 kB 16.7 kB
createApp 54.6 kB 21.3 kB 19.4 kB
createSSRApp 58.9 kB 23 kB 21 kB
defineCustomElement 59.6 kB 22.8 kB 20.9 kB
overall 68.8 kB 26.4 kB 24.2 kB

Copy link

pkg-pr-new bot commented Sep 19, 2025

Open in StackBlitz

@vue/compiler-core

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

@vue/compiler-dom

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

@vue/compiler-sfc

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

@vue/compiler-ssr

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

@vue/reactivity

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

@vue/runtime-core

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

@vue/runtime-dom

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

@vue/server-renderer

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

@vue/shared

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

vue

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

@vue/compat

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

commit: f802d77

@edison1105 edison1105 changed the title fix(sfc): add support for @vue-ignore in runtime type resolution fix(compiler-sfc): add support for @vue-ignore in runtime type resolution Sep 19, 2025
@edison1105 edison1105 added ready to merge The PR is ready to be merged. scope: sfc 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. labels Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. ready to merge The PR is ready to be merged. scope: sfc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant