From 01aa7a6ff452e42e90be95d47e5a116e7249a831 Mon Sep 17 00:00:00 2001 From: Ragg Date: Thu, 1 Mar 2018 00:23:53 +0900 Subject: [PATCH] Improve typing for createStore (review fixes) --- types/dispatchr/addons/createStore.d.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/types/dispatchr/addons/createStore.d.ts b/types/dispatchr/addons/createStore.d.ts index 0c6388d1ae..df8e12cf03 100644 --- a/types/dispatchr/addons/createStore.d.ts +++ b/types/dispatchr/addons/createStore.d.ts @@ -1,13 +1,20 @@ import { StoreClass, Store } from '../index'; +type Diff = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]; +type Omit = Pick>; + interface StoreOptions { - initialize?(): void; storeName: string; handlers: { [event: string]: string }; - [prop: string]: any; + statics?: { [prop: string]: any }; + mixins?: object[]; + initialize?(): void; + dehydrate?(): any; + rehydrate?(state: any): void; } -type CreateStore = (options: This & ThisType) => StoreClass; +// see: https://github.com/yahoo/fluxible/blob/dispatchr-v1.2.0/packages/dispatchr/addons/createStore.js#L9 +type StoreThis = Omit & Store -declare const _: CreateStore; -export = _; +declare function createStore(options: T & ThisType>): StoreClass; +export = createStore;