From 2f5d755b5be7c04f208cbeb7d14beab2cf879344 Mon Sep 17 00:00:00 2001 From: Brian Takita Date: Sun, 26 May 2019 02:11:54 -0400 Subject: [PATCH 1/3] Additional detail to jsdocs for writable, readable, & derived Fixes https://github.com/sveltejs/svelte/issues/2867 --- src/store.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/store.ts b/src/store.ts index 361632b61d..a957ea66aa 100644 --- a/src/store.ts +++ b/src/store.ts @@ -45,8 +45,8 @@ type SubscribeInvalidateTuple = [Subscriber, Invalidater]; /** * Creates a `Readable` store that allows reading by subscription. - * @param value initial value - * @param start start and stop notifications for subscriptions + * @param [value] initial value + * @param [start] start and stop notifications for subscriptions */ export function readable(value: T, start: StartStopNotifier): Readable { return { @@ -56,8 +56,8 @@ export function readable(value: T, start: StartStopNotifier): Readable /** * Create a `Writable` store that allows both updating and reading by subscription. - * @param value initial value - * @param start start and stop notifications for subscriptions + * @param [value] initial value + * @param {StartStopNotifier}[start] start and stop notifications for subscriptions */ export function writable(value: T, start: StartStopNotifier = noop): Writable { let stop: Unsubscriber; @@ -110,9 +110,9 @@ type StoresValues = T extends Readable ? U : /** * Derived value store by synchronizing one or more readable stores and * applying an aggregation function over its input values. - * @param stores input stores - * @param fn function callback that aggregates the values - * @param initial_value when used asynchronously + * @param {Stores} stores input stores + * @param {function(StoresValues,[Subscriber])|Unsubscriber|void}fn function callback that aggregates the values + * @param [initial_value] when used asynchronously */ export function derived( stores: S, From 6fc7001993e31b9d93f37bce4a6fae92fe691c00 Mon Sep 17 00:00:00 2001 From: Brian Takita Date: Sun, 26 May 2019 10:15:13 -0400 Subject: [PATCH 2/3] Apply suggestions from code review Co-Authored-By: Rich Harris --- src/store.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/store.ts b/src/store.ts index a957ea66aa..aff15ff2ca 100644 --- a/src/store.ts +++ b/src/store.ts @@ -45,8 +45,8 @@ type SubscribeInvalidateTuple = [Subscriber, Invalidater]; /** * Creates a `Readable` store that allows reading by subscription. - * @param [value] initial value - * @param [start] start and stop notifications for subscriptions + * @param value initial value + * @param {StartStopNotifier}start start and stop notifications for subscriptions */ export function readable(value: T, start: StartStopNotifier): Readable { return { From a98a70cf832b66f1414caa9156b30f8da3ec9830 Mon Sep 17 00:00:00 2001 From: Brian Takita Date: Sun, 26 May 2019 10:51:49 -0400 Subject: [PATCH 3/3] jsdoc: `derived` second argument * optional first argument is a Stores type * optional second argument is a function that takes a single argument * has a return value --- src/store.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/store.ts b/src/store.ts index aff15ff2ca..e7db228401 100644 --- a/src/store.ts +++ b/src/store.ts @@ -56,8 +56,8 @@ export function readable(value: T, start: StartStopNotifier): Readable /** * Create a `Writable` store that allows both updating and reading by subscription. - * @param [value] initial value - * @param {StartStopNotifier}[start] start and stop notifications for subscriptions + * @param {*=}value initial value + * @param {StartStopNotifier=}start start and stop notifications for subscriptions */ export function writable(value: T, start: StartStopNotifier = noop): Writable { let stop: Unsubscriber; @@ -111,8 +111,8 @@ type StoresValues = T extends Readable ? U : * Derived value store by synchronizing one or more readable stores and * applying an aggregation function over its input values. * @param {Stores} stores input stores - * @param {function(StoresValues,[Subscriber])|Unsubscriber|void}fn function callback that aggregates the values - * @param [initial_value] when used asynchronously + * @param {function(Stores=, function(*)=):*}fn function callback that aggregates the values + * @param {*=}initial_value when used asynchronously */ export function derived( stores: S,