feat(types): infer emits from SetupContext in defineComponent#14687
feat(types): infer emits from SetupContext in defineComponent#14687zhiyuanzmj wants to merge 2 commits intovuejs:mainfrom
Conversation
📝 WalkthroughWalkthroughThis PR refactors the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
Pull request overview
This PR adjusts Vue runtime-core TypeScript types to improve inferring component emits from an explicitly-typed SetupContext parameter in setup().
Changes:
- Simplifies
SetupContextby removing the distributive conditional (E extends any ? ... : never). - Adds a dts test ensuring JSX listeners (e.g.
onFoo) are inferred whensetup()annotatesctxasSetupContext<['foo']>.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/runtime-core/src/component.ts | Changes the exported SetupContext type definition (variance/inference behavior). |
| packages-private/dts-test/defineComponent.test-d.tsx | Adds a dts regression test for emits inference from SetupContext. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/ecosystem-ci run |
|
📝 Ran ecosystem CI: Open
|
Remove the
E extends any ?expression to correctly infer emits from SetupContext.Don't worry, the #2362 issue has been resolved in this PR after 3.3.0-alpha-7.
Summary by CodeRabbit
Refactor
Tests