Skip to content

Commit 3d9a9ab

Browse files
authored
docs: correct the suggested type for custom events without detail (Svelte 4) (#15763)
* docs: correct the suggested type for custom events without detail * docs: generate fixed types for the Svelte 4 event dispatcher
1 parent 2db5bcc commit 3d9a9ab

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

.changeset/fifty-buckets-return.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
correct the suggested type for custom events without detail

packages/svelte/src/index-client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function create_custom_event(type, detail, { bubbles = false, cancelable = false
114114
* The event dispatcher can be typed to narrow the allowed event names and the type of the `detail` argument:
115115
* ```ts
116116
* const dispatch = createEventDispatcher<{
117-
* loaded: never; // does not take a detail argument
117+
* loaded: null; // does not take a detail argument
118118
* change: string; // takes a detail argument of type string, which is required
119119
* optional: number | null; // takes an optional detail argument of type number
120120
* }>();

packages/svelte/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ declare module 'svelte' {
381381
* The event dispatcher can be typed to narrow the allowed event names and the type of the `detail` argument:
382382
* ```ts
383383
* const dispatch = createEventDispatcher<{
384-
* loaded: never; // does not take a detail argument
384+
* loaded: null; // does not take a detail argument
385385
* change: string; // takes a detail argument of type string, which is required
386386
* optional: number | null; // takes an optional detail argument of type number
387387
* }>();

0 commit comments

Comments
 (0)