Skip to content

Commit 8df1237

Browse files
committed
fix: store types
1 parent ddfff4d commit 8df1237

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

packages/svelte/src/runtime/store/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const subscriber_queue = [];
1313
* Creates a `Readable` store that allows reading by subscription.
1414
* @template T
1515
* @param {T} value initial value
16-
* @param {import('./public.js').StartStopNotifier<T>} start
16+
* @param {import('./public.js').StartStopNotifier<T>} [start]
1717
* @returns {import('./public.js').Readable<T>}
1818
*/
1919
export function readable(value, start) {
@@ -26,7 +26,7 @@ export function readable(value, start) {
2626
* Create a `Writable` store that allows both updating and reading by subscription.
2727
* @template T
2828
* @param {T} value initial value
29-
* @param {import('./public.js').StartStopNotifier<T>} start
29+
* @param {import('./public.js').StartStopNotifier<T>} [start]
3030
* @returns {import('./public.js').Writable<T>}
3131
*/
3232
export function writable(value, start = noop) {
@@ -56,16 +56,18 @@ export function writable(value, start = noop) {
5656
}
5757
}
5858
}
59+
5960
/**
6061
* @param {import('./public.js').Updater<T>} fn
6162
* @returns {void}
6263
*/
6364
function update(fn) {
6465
set(fn(value));
6566
}
67+
6668
/**
6769
* @param {import('./public.js').Subscriber<T>} run
68-
* @param {import('./private.js').Invalidator<T>} invalidate
70+
* @param {import('./private.js').Invalidator<T>} [invalidate]
6971
* @returns {import('./public.js').Unsubscriber}
7072
*/
7173
function subscribe(run, invalidate = noop) {
@@ -95,7 +97,7 @@ export function writable(value, start = noop) {
9597
* @template T
9698
* @overload
9799
* @param {S} stores - input stores
98-
* @param {(values: import('./public.js').StoresValues<S>, set: import('./public.js').Subscriber<T>, update: (fn: import('./public.js').Updater<T>) => void) => import('./public.js').Unsubscriber | void} fn - function callback that aggregates the values
100+
* @param {(values: import('./public.js').StoresValues<S>, set: (value: T) => void, update: (fn: import('./public.js').Updater<T>) => void) => import('./public.js').Unsubscriber | void} fn - function callback that aggregates the values
99101
* @param {T} [initial_value] - initial value
100102
* @returns {import('./public.js').Readable<T>}
101103
*/

packages/svelte/src/runtime/store/public.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export type Updater<T> = (value: T) => T;
1414
* This function is called when the first subscriber subscribes.
1515
*
1616
* @param {(value: T) => void} set Function that sets the value of the store.
17-
* @param {(value: Updater<T>) => void} set Function that sets the value of the store after passing the current value to the update function.
17+
* @param {(value: Updater<T>) => void} update Function that sets the value of the store after passing the current value to the update function.
1818
* @returns {void | (() => void)} Optionally, a cleanup function that is called when the last remaining
1919
* subscriber unsubscribes.
2020
*/

0 commit comments

Comments
 (0)