diff --git a/src/types.ts b/src/types.ts index 5bacf08..782d9a7 100644 --- a/src/types.ts +++ b/src/types.ts @@ -12,4 +12,5 @@ export type Mutation = (payload: any, action: Action) => (state: S) => S export type ActionCreator = (...args: any[] ) => Action; export type UpduxConfig = Partial<{ + subduxes: {} }>; diff --git a/src/updux.js b/src/updux.ts similarity index 81% rename from src/updux.js rename to src/updux.ts index 44d6303..1af27a5 100644 --- a/src/updux.js +++ b/src/updux.ts @@ -6,14 +6,17 @@ import buildMutations from './buildMutations'; import buildCreateStore from './buildCreateStore'; import buildMiddleware from './buildMiddleware'; import buildUpreducer from './buildUpreducer'; +import { UpduxConfig, Dictionary } from './types'; export class Updux { - constructor(config) { + subduxes: Dictionary; + + constructor(config: UpduxConfig) { this.subduxes = fp.mapValues( - value => fp.isPlainObject(value) ? new Updux(value ) : value )(fp.getOr({},'subduxes',config) - ); + (value:UpduxConfig|Updux) => fp.isPlainObject(value) ? new Updux(value) : value )(fp.getOr({},'subduxes',config) + ) as Dictionary; this.actions = buildActions(