-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
[feat] add convenience type for ComponentEvents
#7702
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, this looks good! See review comments for things I'd like to change.
Co-authored-by: Simon H <[email protected]>
ComponentEvents, ComponentEvent and ComponentSlotsComponentEvents, ComponentEvent
ComponentEvents, ComponentEventComponentEvents and ComponentEvent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, thanks for the PR! ComponentEvents is pretty nice to have indeed, though I can't seem to say the same about ComponentEvent. We can already achieve the same thing with ComponentEvents<Component>['close'], and this makes more sense to me as it also aligns with how TypeScript provides their utility types, e.g. Parameters and without the singular Parameter.
Co-authored-by: Ignatius Bagus <[email protected]>
Co-authored-by: Ignatius Bagus <[email protected]>
Co-authored-by: Ignatius Bagus <[email protected]>
I know I can get a single event with the |
|
@ignatiusmb has a point here - let's keep it simple for now and remove the |
ComponentEvents and ComponentEventComponentEvents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
|
This has been released in 3.50.0. Thank you! |
Before submitting the PR, please make sure you do the following
[feat],[fix],[chore], or[docs].Tests
npm testand lint the project withnpm run lintThis extends the convenience types of #6770 with
ComponentEventsto get all events of a componentuse-case: wrapping a component and re-declaring its events
https://github.com/ivanhofer/sveltekit-typescript-showcase/blob/main/src/03-events/04-%24%24Events/Component.svelte
ComponentEventto get the type of a single event of a componentuse-case: typing an event handler
https://github.com/ivanhofer/sveltekit-typescript-showcase/blob/main/src/03-events/02-typed-event-details/Usage.svelte
ComponentSlotsto get all slots of a componentuse-case: none, that I currently can think of, but it makes sense to also provide this type helper