diff --git a/redux-actions/index.d.ts b/redux-actions/index.d.ts index 6776f2b621..e174683b88 100644 --- a/redux-actions/index.d.ts +++ b/redux-actions/index.d.ts @@ -91,12 +91,14 @@ declare namespace ReduxActions { export function handleAction( actionType: string | ActionFunctions, - reducer: Reducer | ReducerNextThrow + reducer: Reducer | ReducerNextThrow, + initialState: State ): Reducer; export function handleAction( actionType: { toString(): string }, - reducer: ReducerMeta | ReducerNextThrowMeta + reducer: ReducerMeta | ReducerNextThrowMeta, + initialState: State ): Reducer; export function handleActions( diff --git a/redux-actions/redux-actions-tests.ts b/redux-actions/redux-actions-tests.ts index f5a2d41e18..237d7fa04f 100644 --- a/redux-actions/redux-actions-tests.ts +++ b/redux-actions/redux-actions-tests.ts @@ -15,7 +15,8 @@ const action: ReduxActions.Action = incrementAction(); const actionHandler = ReduxActions.handleAction( 'INCREMENT', - (state: number, action: ReduxActions.Action) => state + action.payload + (state: number, action: ReduxActions.Action) => state + action.payload, + 0 ); state = actionHandler(0, incrementAction()); @@ -26,7 +27,8 @@ const actionHandlerWithReduceMap = ReduxActions.handleAction( return state * action.payload; }, throw(state: number) { return state } - } + }, + 0 ); state = actionHandlerWithReduceMap(0, multiplyAction(10)); @@ -83,7 +85,8 @@ const typedIncrementAction: () => ReduxActions.Action = ReduxActio const typedActionHandler = ReduxActions.handleAction( 'INCREMENT', - (state: TypedState, action: ReduxActions.Action) => ({ value: state.value + 1 }) + (state: TypedState, action: ReduxActions.Action) => ({ value: state.value + 1 }), + {value: 1} ); typedState = typedActionHandler({ value: 0 }, typedIncrementAction()); @@ -101,7 +104,8 @@ const typedActionHandlerWithReduceMap = ReduxActions.handleAction(act, (state, action) => { return { hello: action.payload } -}) +}, {hello: 'greetings'}) ReduxActions.handleAction<{ hello: { load: boolean } }, { load: boolean }>(act2, (state, action) => { return { hello: action.payload } -}) +}, {hello: {load: true}}) ReduxActions.handleAction(act3, (state, action) => { return { hello: action.payload.s } -}) +}, {hello: 'greetings'}) -ReduxActions.handleAction(ReduxActions.combineActions(act, act3, act2), () => { +ReduxActions.handleAction(ReduxActions.combineActions(act, act3, act2), (state, action) => { -}) +}, 0) /* can't do this until it lands in 2.2, HKTs ReduxActions.handleAction(act, (state, action) => {