-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
feat(types): enhance the event type in defineEmits #8332
Conversation
Thanks for the PR - could you please add type tests in https://github.com/vuejs/core/blob/main/packages/dts-test/setupHelpers.test-d.ts? |
I'm planning to do this! |
This feature is imperfect because I do not know how to change the parameter type for an overloaded function. 🤔 |
All usage scenarios are currently supported! |
After testing this locally, it seems this doesn't actually fix vuejs/language-tools#3197 - the actual issue seems to be in Volar, not in the types of The kebab-case and camelCase conversions are mostly meant for parent consumers. Locally, |
You're right! The format conversion accommodates how the template is written. For event firing, we supposedly need to keep the event names consistent. |
The original intention of this PR is to keep defineEmits consistent in logic and type. Still, from the perspective of developing components, it will undoubtedly confuse the code specification of components. I was going in the wrong direction for vuejs/language-tools#3197; we should enhance type hints on component usage in SFC. |
I think we can agree to close this one then? Regardless, thanks for your effort on the PR 👍 |
I think so too. Thank you for your patience and strict control over the code design. I learned quite a bit about TypeScript on this PR. |
closes vuejs/language-tools#3197
Enhance the event type in
defineEmits
so that it conforms to the triggering mechanism of emit.For normal events, we allow them to contain camelized copies:
For v-model update:xxx events, we allow them to contain hyphenate copies:
It also filters the types that already exist and are defined in events: