From 8f500f66d136bf6c87425852bf90ea3814a346bb Mon Sep 17 00:00:00 2001 From: Jonathan Santerre Date: Thu, 7 May 2020 09:05:28 -0400 Subject: [PATCH] Add generic for store state type (#267) --- src/index.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index 673f633..d8afe71 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,25 +8,27 @@ interface Storage { removeItem: (key: string) => void; } -interface Options { +interface Options { key?: string; paths?: string[]; reducer?: (state: any, paths: string[]) => object; subscriber?: ( - store: typeof Store + store: Store ) => (handler: (mutation: any, state: any) => void) => void; storage?: Storage; getState?: (key: string, storage: Storage) => any; - setState?: (key: string, state: typeof Store, storage: Storage) => void; + setState?: (key: string, state: Store, storage: Storage) => void; filter?: (mutation: MutationPayload) => boolean; arrayMerger?: (state: any, saved: any) => any; - rehydrated?: (store: typeof Store) => void; + rehydrated?: (store: Store) => void; fetchBeforeUse?: boolean; overwrite?: boolean; assertStorage?: (storage: Storage) => void | Error; } -export default function (options?: Options) { +export default function ( + options?: Options +): (store: Store) => void { options = options || {}; const storage = options.storage || (window && window.localStorage);