fix(compiler-sfc): handle vue-ignore on leading intersection type#14950
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughCentralizes ChangesLeading Intersection/Union Ignore Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts (1)
156-166: ⚡ Quick winAdd a leading-union ignore regression case next to this test.
Line 156 covers the new leading-intersection behavior, but the same resolver branch also handles leading unions. A sibling test would lock that path too.
Suggested test addition
+ test('leading union type with ignore', () => { + expect( + resolve(` + type Foo = { foo: number } + type Bar = { bar: boolean } + defineProps</* `@vue-ignore` */ Foo | Bar>() + `).props, + ).toStrictEqual({ + bar: ['Boolean'], + }) + })🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts` around lines 156 - 166, Add a sibling test case to cover the leading-union with ignore scenario next to the existing test 'leading intersection type with ignore'; specifically, add a test that calls resolve(...) with a leading union type annotated like defineProps</* `@vue-ignore` */ Foo | Bar>() (matching the structure used in the intersection test) and assert the resulting .props shape (e.g., that only the expected prop from the non-ignored type is present). Use the same resolve helper and test structure as the existing test to lock the resolver branch that handles leading unions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts`:
- Around line 156-166: Add a sibling test case to cover the leading-union with
ignore scenario next to the existing test 'leading intersection type with
ignore'; specifically, add a test that calls resolve(...) with a leading union
type annotated like defineProps</* `@vue-ignore` */ Foo | Bar>() (matching the
structure used in the intersection test) and assert the resulting .props shape
(e.g., that only the expected prop from the non-ignored type is present). Use
the same resolve helper and test structure as the existing test to lock the
resolver branch that handles leading unions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8844ccf4-536b-437b-8af2-2e65a83c0baf
📒 Files selected for processing (3)
packages/compiler-sfc/__tests__/compileScript/defineProps.spec.tspackages/compiler-sfc/__tests__/compileScript/resolveType.spec.tspackages/compiler-sfc/src/script/resolveType.ts
|
/ecosystem-ci run |
|
📝 Ran ecosystem CI: Open
|
89c08ab to
19672bb
Compare
Fixes #12254.
When
@vue-ignoreis placed before the first member of an intersection type, Babel attaches the leading comment to the parentTSIntersectionTypeinstead of the first type reference. The SFC type resolver then treats the whole intersection as ignored, so later members are skipped and their runtime prop types are not generated.This changes that specific case so a leading
@vue-ignoreon an intersection/union parent is treated as applying to the first member only. Other members continue to be resolved normally, preserving boolean runtime prop inference for cases likedefineProps</* @vue-ignore */ A & B>().Test
pnpm vitest run packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts packages/compiler-sfc/__tests__/compileScript/defineProps.spec.ts packages/compiler-sfc/__tests__/compileScript.spec.tspnpm exec prettier --check packages/compiler-sfc/src/script/resolveType.ts packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts packages/compiler-sfc/__tests__/compileScript/defineProps.spec.tspnpm exec eslint packages/compiler-sfc/src/script/resolveType.ts packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts packages/compiler-sfc/__tests__/compileScript/defineProps.spec.tspnpm checkgit diff --checkSummary by CodeRabbit
Bug Fixes
Tests