From 5a0fb7ddae267255e72c971470e106807b550887 Mon Sep 17 00:00:00 2001 From: vrde Date: Fri, 11 Mar 2022 00:05:22 +0100 Subject: [PATCH] Export types needed for defining custom stores I wrote a custom store to have a more flexible `derived` store. The function signatures looks like: ```typescript export function derivedWritable( stores: S, fn: (values: StoresValues, set: (value: T) => void) => Unsubscriber | void, initial_value?: T ): Writable { ... } ``` Both `Stores` and `StoresValues` are not exported in `svelte/store`. I had to copy paste the type definition from this file and duplicate code. Unless I'm using TypeScript wrong (I'm still quite new to it), I think these types plus few others should be exported. --- src/runtime/store/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/runtime/store/index.ts b/src/runtime/store/index.ts index e947fa074028..1a25bb98fd76 100644 --- a/src/runtime/store/index.ts +++ b/src/runtime/store/index.ts @@ -10,7 +10,7 @@ export type Unsubscriber = () => void; export type Updater = (value: T) => T; /** Cleanup logic callback. */ -type Invalidator = (value?: T) => void; +export type Invalidator = (value?: T) => void; /** Start and stop notification callbacks. */ export type StartStopNotifier = (set: Subscriber) => Unsubscriber | void; @@ -41,7 +41,7 @@ export interface Writable extends Readable { } /** Pair of subscriber and invalidator. */ -type SubscribeInvalidateTuple = [Subscriber, Invalidator]; +export type SubscribeInvalidateTuple = [Subscriber, Invalidator]; const subscriber_queue = []; @@ -109,10 +109,10 @@ export function writable(value?: T, start: StartStopNotifier = noop): Writ } /** One or more `Readable`s. */ -type Stores = Readable | [Readable, ...Array>] | Array>; +export type Stores = Readable | [Readable, ...Array>] | Array>; /** One or more values from `Readable` stores. */ -type StoresValues = T extends Readable ? U : +export type StoresValues = T extends Readable ? U : { [K in keyof T]: T[K] extends Readable ? U : never }; /**