-
-
Notifications
You must be signed in to change notification settings - Fork 9k
fix(compiler-sfc): handle indexed access types in declare global blocks #14260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThe changes add support for resolving indexed access types within global ambient declarations by implementing recursive processing of Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts (1)
1470-1488: Test validates the fix, but consider enhancing coverage.The test correctly validates that indexed access types work with global declarations. It should pass with the implementation changes in
resolveType.ts.However, issue #14236 specifically mentions
Record<string, unknown>within global indexed types causing errors. Consider adding a test case that includes this pattern for more comprehensive validation:Optional: Enhanced test case with Record
test('declare global with indexed access type and Record', () => { const files = { '/global.d.ts': ` declare global { type Options = { code: { selected: boolean metadata: Record<string, unknown> } } }`, } const { props } = resolve(`defineProps<Options["code"]>()`, files, { globalTypeFiles: Object.keys(files), }) expect(props).toStrictEqual({ selected: ['Boolean'], metadata: ['Object'], }) })
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/compiler-sfc/__tests__/compileScript/resolveType.spec.tspackages/compiler-sfc/src/script/resolveType.ts
🔇 Additional comments (1)
packages/compiler-sfc/src/script/resolveType.ts (1)
1391-1402: Well-structured fix for global block type recording.The implementation correctly handles
declare globalblocks by recursively processing their contents and recording type declarations. The special handling forExportNamedDeclarationat lines 1395-1396 ensures exported types within global blocks are captured, while the else branch handles regular declarations. The short-circuit break at line 1401 appropriately prevents normal module declaration processing.This change enables indexed access types on global declarations (e.g.,
Options["code"]) to resolve correctly, addressing issue #14236.
close #14236
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.