salvoravida/redux-first-history

Add Actions union type

whazor opened this issue · 1 comments

With redux-observable it is a pattern to have all actions as a union type, it would be nice if this library also exports an union of all possible action types. This would not require any new dependency as it is pure TypeScript.

I currently added the union typing for my project this way, but implementation would be a bit cleaner:

import {
    push,
    replace,
    go,
    goBack,
    goForward
 } from "redux-first-history";

import { locationChangeAction, back, forward } from "redux-first-history/build/es6/actions";

declare module "redux-first-history" {
    export type RouterActions = 
        ReturnType<typeof push> | 
        ReturnType<typeof replace> |
        ReturnType<typeof go> | 
        ReturnType<typeof goBack> | 
        ReturnType<typeof goForward> | 
        ReturnType<typeof locationChangeAction> | 
        ReturnType<typeof back> |
        ReturnType<typeof forward>;
}

@whazor yeah open a PR!