Skip to content
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

Merged
merged 12 commits into from Jul 25, 2022

Conversation

ivanhofer
Copy link
Contributor

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with [feat], [fix], [chore], or [docs].
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with npm test and lint the project with npm run lint

This extends the convenience types of #6770 with

Copy link
Member

@dummdidumm dummdidumm left a 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.

src/runtime/internal/dev.ts Outdated Show resolved Hide resolved
src/runtime/internal/dev.ts Outdated Show resolved Hide resolved
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
@ivanhofer ivanhofer changed the title [feat] add convenience types ComponentEvents, ComponentEvent and ComponentSlots [feat] add convenience types ComponentEvents, ComponentEvent Jul 20, 2022
@ivanhofer ivanhofer changed the title [feat] add convenience types ComponentEvents, ComponentEvent [feat] add convenience types ComponentEvents and ComponentEvent Jul 20, 2022
Copy link
Member

@ignatiusmb ignatiusmb left a 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.

src/runtime/internal/dev.ts Outdated Show resolved Hide resolved
generate-type-definitions.js Outdated Show resolved Hide resolved
src/runtime/internal/dev.ts Outdated Show resolved Hide resolved
ivanhofer and others added 3 commits July 20, 2022 19:56
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>
@ivanhofer
Copy link
Contributor Author

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.

I know I can get a single event with the ComponentEvents<Component>['close'] syntax. But other people may find the syntax confusing. That's why I have added a second type.
Another option could be to create a single ComponentEvents type with an optional second generic. That type then either returns the full object or the type of a single event.

@dummdidumm
Copy link
Member

@ignatiusmb has a point here - let's keep it simple for now and remove the ComponentEvent type.

@ivanhofer ivanhofer changed the title [feat] add convenience types ComponentEvents and ComponentEvent [feat] add convenience type for ComponentEvents Jul 25, 2022
Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@dummdidumm dummdidumm merged commit bb02a22 into sveltejs:master Jul 25, 2022
@Conduitry
Copy link
Member

This has been released in 3.50.0. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants