ts-action-creator
simple library which will let you create typed actions for reducers.
npm i --save ts-action-creator
import {makeAction} from 'ts-action-creator'
const myTypedAction = makeAction<{value : string}>('MY_TYPED_ACTION_NAME'); // creating action
// will be dispatched as {type : 'MY_TYPED_ACTION_NAME' , payload : {value : 'value'}}
dispatch(myTypedAction({value : "my value"}));
function reducer(state = {} , action : Action) {
if(myTypedAction.match(action)) { // Usage in reducer
return state;
}
}
createdAction.type // Contains action type