-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
fix(compiler-sfc): improve type inference for generic type aliases types #12876
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
Conversation
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: |
@edison1105 Thanks for implementing this bug fix! Is there something blocking this PR from being merged and released? |
WalkthroughExtends compiler-sfc’s runtime type inference to propagate and resolve generic type parameters across references, unions, and intersections. Updates tests to expect multiple concrete runtime types from union/intersection resolutions, including correct inference for generics. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as SFC Script
participant CS as compileScript
participant RT as inferRuntimeType
participant TR as resolveTypeRef
participant FL as flattenTypes
Dev->>CS: defineProps<T>()
CS->>RT: inferRuntimeType(node, scope, isKeyOf, typeParameters?)
alt T is TSTypeReference
RT->>TR: resolve referenced alias/decl
alt Alias has its own type params
RT->>RT: map alias params -> actual args (typeParameters)
else Top-level type parameter
RT->>RT: substitute from typeParameters
end
RT->>RT: recurse into alias typeAnnotation with mapped typeParameters
else T is TSUnion/TSIntersection
RT->>FL: flattenTypes(T, typeParameters)
FL->>RT: infer per member with typeParameters
RT->>RT: merge and filter UNKNOWN_TYPE (for intersections)
else TSFunctionType alias
RT-->>CS: ["Function"]
end
CS-->>Dev: props schema with concrete runtime types (e.g., Boolean)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changes(No out-of-scope functional changes identified.) Possibly related PRs
Suggested reviewers
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (2)
🧰 Additional context used🧬 Code Graph Analysis (1)packages/compiler-sfc/src/script/resolveType.ts (2)
⏰ 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). (1)
🔇 Additional comments (8)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
close #12872
Summary by CodeRabbit