Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

th0rgall
Copy link

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. -> NA
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm 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 the never type can be used for this. However, when doing this, I'm getting a Typescript error Expected 2-3 arguments, but got 1 when calling createEventDispatcher.

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!

Copy link

changeset-bot bot commented Apr 14, 2025

🦋 Changeset detected

Latest commit: 15b66b5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

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

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.

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 👍

@svelte-docs-bot
Copy link

@th0rgall
Copy link
Author

It was a very understandable oversight 🙂 And I didn't realize I had to generate the types, done now!

Copy link
Contributor

Playground

pnpm add https://pkg.pr.new/svelte@15763

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.

2 participants