-
-
Notifications
You must be signed in to change notification settings - Fork 420
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
Event type bug in template #1855
Comments
Faced the issue too. There is a weird hack const emit = defineEmits<{
(e: "event-any", arg: any): void;
(e: "__", arg: any): void; // this line fixes the issue
(e: "event-str", arg: string): void;
}>(); |
@johnsoncodehk asked me to post my use case related to this issue. In Vue 2.7, options API (defineComponent), TS 5, Volar 1.6.1, type of event is wrong in VSCode It should have been 'event-without-payload': ($event?: undefined) => void Also, it would have been nice that Volar throw a typescript error on handleEventWithPayload in the template has handleEventWithPayload does not satisfy the type emits: {
'event-without-payload': (): void => { },
'event-with-payload': (a: number, b: boolean) => { }
} For reproduction repo, you can take the same as the issue 2742 (https://github.com/vidal7/volar-issue-2742) |
Reproduction: https://github.com/kingyue737/volar-event-bug
pnpm install
App.vue
Event
event-any
is defined witharg: any
but volar thinks the type of handler should be(arg: string) => void
It seems this issue happens when one of the events has an argument typed as
any
While volar extension shows ts error in template,
vue-tsc
doesn't complain about such issue.Environment
The text was updated successfully, but these errors were encountered: