-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[feat] add convenience type for ComponentEvents
#7702
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 <5968653+dummdidumm@users.noreply.github.com>
ComponentEvents
, ComponentEvent
and ComponentSlots
ComponentEvents
, ComponentEvent
ComponentEvents
, ComponentEvent
ComponentEvents
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 <ignatius.mbs@gmail.com>
Co-authored-by: Ignatius Bagus <ignatius.mbs@gmail.com>
Co-authored-by: Ignatius Bagus <ignatius.mbs@gmail.com>
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 ComponentEvent
ComponentEvents
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 test
and lint the project withnpm run lint
This extends the convenience types of #6770 with
ComponentEvents
to 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
ComponentEvent
to 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
ComponentSlots
to get all slots of a componentuse-case: none, that I currently can think of, but it makes sense to also provide this type helper