diff --git a/types/redux-actions/index.d.ts b/types/redux-actions/index.d.ts index b4aaa8474e..d5b825e28c 100644 --- a/types/redux-actions/index.d.ts +++ b/types/redux-actions/index.d.ts @@ -58,6 +58,10 @@ export type ActionFunction3 = (t1: T1, t2: T2, t3: T3) => R; export type ActionFunction4 = (t1: T1, t2: T2, t3: T3, t4: T4) => R; export type ActionFunctionAny = (...args: any[]) => R; +export function createAction( + actionType: string +): ActionFunction0>; + export function createAction( actionType: string, payloadCreator: ActionFunction0 @@ -85,7 +89,7 @@ export function createAction( export function createAction( actionType: string -): ActionFunctionAny>; +): ActionFunction1>; export function createAction( actionType: string, diff --git a/types/redux-actions/redux-actions-tests.ts b/types/redux-actions/redux-actions-tests.ts index f2d7cef7d1..e4c51aa662 100644 --- a/types/redux-actions/redux-actions-tests.ts +++ b/types/redux-actions/redux-actions-tests.ts @@ -110,8 +110,11 @@ const typedActionHandlerWithReduceMap = ReduxActions.handleAction('ACTION1'); -act('hello').payload === 'hello'; +const act0 = ReduxActions.createAction('ACTION0'); +act0().payload === null; + +const act1 = ReduxActions.createAction('ACTION1'); +act1('hello').payload === 'hello'; const act2 = ReduxActions.createAction('ACTION2', (s: {load: boolean}) => s); act2({load: true}).payload.load === true; @@ -119,7 +122,7 @@ act2({load: true}).payload.load === true; const act3 = ReduxActions.createAction('ACTION3', (s: string) => ({s})); act3('hello').payload.s === 'hello'; -ReduxActions.handleAction<{ hello: string }, string>(act, (state, action) => { +ReduxActions.handleAction<{ hello: string }, string>(act1, (state, action) => { return { hello: action.payload }; }, {hello: 'greetings'}); @@ -131,7 +134,7 @@ ReduxActions.handleAction(act3, (state, action) => { return { hello: action.payload.s }; }, {hello: 'greetings'}); -ReduxActions.handleAction(ReduxActions.combineActions(act, act3, act2), (state, action) => {}, 0); +ReduxActions.handleAction(ReduxActions.combineActions(act1, act3, act2), (state, action) => {}, 0); /* can't do this until it lands in 2.2, HKTs ReduxActions.handleAction(act, (state, action) => {