diff --git a/src/buildCreateStore.js b/src/buildCreateStore.js deleted file mode 100644 index 76654ba..0000000 --- a/src/buildCreateStore.js +++ /dev/null @@ -1,17 +0,0 @@ -import { createStore as reduxCreateStore, applyMiddleware } from 'redux'; - -export default function buildCreateStore( reducer, initial, middleware, - actions ) { - return () => { - const store = reduxCreateStore( reducer, initial, - applyMiddleware( middleware) - ); - for ( let a in actions ) { - store.dispatch[a] = (...args) => { - store.dispatch(actions[a](...args)) - }; - } - - return store; - } -}; diff --git a/src/buildCreateStore/index.ts b/src/buildCreateStore/index.ts new file mode 100644 index 0000000..650c448 --- /dev/null +++ b/src/buildCreateStore/index.ts @@ -0,0 +1,31 @@ +import { + createStore as reduxCreateStore, + applyMiddleware, + Middleware, + Reducer, +} from 'redux'; +import { ActionCreator, Dictionary } from '../types'; + +function buildCreateStore( + reducer: Reducer, + initial: S, + middleware: Middleware, + actions: Dictionary, +) { + return () => { + const store = reduxCreateStore( + reducer, + initial, + applyMiddleware(middleware), + ); + for (let a in actions) { + ( store.dispatch as any)[a] = (...args: any[]) => { + store.dispatch(actions[a](...args)); + }; + } + + return store; + }; +} + +export default buildCreateStore;