Typescript and createEventDispatcher
#3991
-
HI there, how can I give dispatched events types? const dispatch = createEventDispatcher();
// ...
dispatch('eventName', { id: 'id123' , type: 'abc' } What's the best way of telling Typescript that for dispatched events of type Any help is appreciated. 🙏 |
Beta Was this translation helpful? Give feedback.
Answered by
mustofa-id
Feb 18, 2022
Replies: 1 comment 2 replies
-
Sound more Svelte than Kit. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
b2m9
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sound more Svelte than Kit.
You can type event name and detail like so:
createEventDispatcher<{eventName: { id: string, type: striing }}>()