Skip to content
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

toggle event throws error on details element #10928

Closed
Lenni009 opened this issue May 12, 2024 · 1 comment · Fixed by #10938
Closed

toggle event throws error on details element #10928

Lenni009 opened this issue May 12, 2024 · 1 comment · Fixed by #10938
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. 🐞 bug Something isn't working scope: types

Comments

@Lenni009
Copy link

Description

When putting an @toggle event handler on a <details> element, the type checking fails with this error:

src/App.vue:6:13 - error TS2322: Type '() => void' is not assignable to type 'Event'.

<details @toggle="sayHi">

node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts:444:5
onToggle?: Event;

The expected type comes from property 'onToggle' which is declared here on type 'DetailsHTMLAttributes & ReservedProps & Record<string, unknown>'

Expected Behaviour

Since toggle is a standard DOM event, I want to be able to hook up an event listener to that event.

It works in the 1.x versions of vue-tsc, and also works when Typescript isn't used.

Workaround

When using the old element.addEventListener('toggle', () => {}); syntax, there is no error.

Reproduction

Minimal reproduction: https://github.com/Lenni009/vue-details-toggle-event-issue

@johnsoncodehk
Copy link
Member

johnsoncodehk commented May 13, 2024

It's type issue from @vue/runtime-dom, the type of onToggle should be (payload: MouseEvent) => void instead of MouseEvent.

@LinusBorg could you transfer this issue?

@LinusBorg LinusBorg transferred this issue from vuejs/language-tools May 13, 2024
@LinusBorg LinusBorg added 🐞 bug Something isn't working scope: types labels May 13, 2024
@sodatea sodatea added the 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. label May 13, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. 🐞 bug Something isn't working scope: types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants