Handling multiple event handlers in components with typescript #12468
Answered
by
brunnerh
ananduremanan
asked this question in
Q&A
-
Hi there, When creating a component with typescript, do I need to specify every event handlers and it's type? for eg: In my button component
I passed {...props} for handling multiple event handlers and when I use the component
I'm getting a type error
and I don't know how to use |
Beta Was this translation helpful? Give feedback.
Answered by
brunnerh
Jul 17, 2024
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ananduremanan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
svelte/elements
, which include all the event handlers, in this caseHTMLButtonAttributes
so e.g.let { ... }: ButtonProps & HTMLButtonAttributes = $props();
; alterniatevly define it as a separate type/makeButtonProps
extend the attrbutes.class
can be aliased on destructuring if you need it as a separate property, but in your first example it would just be part of therest
object, i.e.rest.class
.