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

[Switch]: [Property 'checked' does not exist on type 'EventTarget'] #6136

Closed
1 task done
22shubham22 opened this issue Jul 30, 2024 · 2 comments · Fixed by #6167
Closed
1 task done

[Switch]: [Property 'checked' does not exist on type 'EventTarget'] #6136

22shubham22 opened this issue Jul 30, 2024 · 2 comments · Fixed by #6167
Labels
bug Something isn't working released

Comments

@22shubham22
Copy link

Describe the bug

onChange | Fired when the component checked state changes.

Note: Call event.preventDefault() inside the handler of this event to prevent its default action/s.

(event: Ui5CustomEvent<SwitchDomRef, never>) => void

When we assign this type to the event Ui5CustomEvent<SwitchDomRef, never> , we see an error in typescript when we try to access -> event.currentTarget?.checked that says -> Property 'checked' does not exist on type 'EventTarget'

Although , when we console log it , we get the desired value .

Isolated Example

https://stackblitz.com/edit/github-ekiatg?file=src%2FApp.tsx

Reproduction steps

  1. Create a switch component with onChange Event of type Ui5CustomEvent<SwitchDomRef, never> in typescript
  2. Try console.log(event.currentTarget?.checked)
  3. the error you get is : Property 'checked' does not exist on type 'EventTarget'
    ...

Expected Behaviour

No response

Screenshots or Videos

Screenshot 2024-07-30 at 3 53 09 PM

UI5 Web Components for React Version

1.29.0

UI5 Web Components Version

1.24.0

Browser

Chrome

Operating System

Mac

Additional Context

No response

Relevant log output

No response

Organization

No response

Declaration

  • I’m not disclosing any internal or sensitive information.
@22shubham22 22shubham22 added the bug Something isn't working label Jul 30, 2024
@MarcusNotheis
Copy link
Contributor

MarcusNotheis commented Jul 31, 2024

Hi @22shubham22,
thanks for reaching out! Is there any specific reason why you need to use currentTarget instead of target? Our type definition adds the types of the UI5 Web Component to the target property of the custom event, but not to the currentTarget as the event might bubble up from somewhere else.
We'll add the types for currentTarget.

@ui5-webcomponents-react-bot
Copy link
Contributor

🎉 This issue has been resolved in version v2.0.0-rc.2 🎉

The release is available on v2.0.0-rc.2

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
Status: 🆕 New
Development

Successfully merging a pull request may close this issue.

4 participants