-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
docs: correct the suggested type for custom events without detail (Svelte 4) #15763
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
🦋 Changeset detectedLatest commit: 15b66b5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
You're right, we've tried never
at one point but it resulted in problems so we changed it; guess we never changed the docs for it.
You gotta regenerate the types (pnpm generate:types
within packages/svelte
+ commit), then we're good to merge 👍
It was a very understandable oversight 🙂 And I didn't realize I had to generate the types, done now! |
|
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!
'svelte': patch | ||
--- | ||
|
||
correct the suggested type for custom events without detail |
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.
correct the suggested type for custom events without detail | |
fix: adjust suggested type for custom events without detail |
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.packages/svelte/src
, add a changeset (npx changeset
).Tests and linting
pnpm test
and lint the project withpnpm lint
Tests are OK, except for those using Playwright, which I didn't install. Linting crashes for me with an Eslint "Cannot find module" error. I'm holding off on fixing these setup issues, I'm not sure if it's worth it for a one-word docs change.
I tried to follow the guidance given by the docs for
createEventDispatcher
to type a custom event without a detail argument. The function documentation mentions that thenever
type can be used for this. However, when doing this, I'm getting a Typescript errorExpected 2-3 arguments, but got 1
when callingcreateEventDispatcher
.I searched the dedicated v4 docs site and found this section on createEventDispatcher which includes
event: null; // does not accept a payload
. I assume that "payload" & "detail" mean the same thing, and that suggesting to use "never" was a mistake in the function docs (or something that was never updated). With "null" it works as expected!