[Switch]: [Property 'checked' does not exist on type 'EventTarget']
22shubham22 opened this issue · 2 comments
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
- Create a switch component with onChange Event of type Ui5CustomEvent<SwitchDomRef, never> in typescript
- Try console.log(event.currentTarget?.checked)
- the error you get is : Property 'checked' does not exist on type 'EventTarget'
...
Expected Behaviour
No response
Screenshots or Videos
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.
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
.
🎉 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 📦🚀