Skip to content

Instantly share code, notes, and snippets.

@theory-of-soul
Last active April 16, 2019 10:10
Show Gist options
  • Save theory-of-soul/081084067f0cc6b8ed94299a4d7be02e to your computer and use it in GitHub Desktop.
Save theory-of-soul/081084067f0cc6b8ed94299a4d7be02e to your computer and use it in GitHub Desktop.
Typed immutable map for redux state
type StateType = {
router: RouterState;
someReducer: Immutable.Map<keyof SomeReducerType, SomeReducerType[keyof SomeReducerType]>;
}
export interface AppStateInterface extends Immutable.Map<string, any> {
toJS(): StateType;
get<K extends keyof StateType>(key: K, notSetValue?: StateType[K]): StateType[K];
set<K extends keyof StateType>(key: K, value: StateType[K]): this;
has(key: string): key is keyof StateType;
merge(...collections: Array<Partial<StateType> | Iterable<[string, any]>>): this;
mergeDeep(...collections: Array<Partial<StateType> | Iterable<[string, any]>>): this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment