Created
January 20, 2018 19:33
-
-
Save flushentitypacket/9775421e4c69752fa5a20e92cec8edf6 to your computer and use it in GitHub Desktop.
Typescript Redux generic Action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// store/redux.d.ts | |
import {Action as ReduxAction} from 'redux' | |
export interface Action< | |
T extends string, | |
P = undefined | |
> extends ReduxAction { | |
type: T | |
payload: P | |
} | |
// example use | |
const TOGGLE = 'toggle' | |
interface ActionToggle extends Action<typeof TOGGLE> {} | |
const ADD = 'add' | |
interface ActionAdd extends Action<typeof ADD, number> {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment