mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-03-01 04:02:55 +00:00
Merge pull request #21498 from lsanwick/master
[redux-actions] Update definition to support nested reducer maps
This commit is contained in:
commit
db4cffca91
4
types/redux-actions/index.d.ts
vendored
4
types/redux-actions/index.d.ts
vendored
@ -22,8 +22,10 @@ export interface ActionMeta<Payload, Meta> extends Action<Payload> {
|
||||
meta: Meta;
|
||||
}
|
||||
|
||||
export type ReducerMapValue<State, Payload> = Reducer<State, Payload> | ReducerNextThrow<State, Payload> | ReducerMap<State, Payload>;
|
||||
|
||||
export interface ReducerMap<State, Payload> {
|
||||
[actionType: string]: Reducer<State, Payload> | ReducerNextThrow<State, Payload>;
|
||||
[actionType: string]: ReducerMapValue<State, Payload>;
|
||||
}
|
||||
|
||||
export interface ReducerMapMeta<State, Payload, Meta> {
|
||||
|
||||
@ -51,6 +51,15 @@ const actionsHandlerWithInitialState = ReduxActions.handleActions({
|
||||
|
||||
state = actionsHandlerWithInitialState(0, { type: 'INCREMENT' });
|
||||
|
||||
const actionsHandlerWithRecursiveReducerMap = ReduxActions.handleActions<number, number>({
|
||||
ADJUST: {
|
||||
UP: (state: number, action: ReduxActions.Action<number>) => state + action.payload,
|
||||
DOWN: (state: number, action: ReduxActions.Action<number>) => state - action.payload,
|
||||
}
|
||||
}, 0);
|
||||
|
||||
state = actionsHandlerWithRecursiveReducerMap(0, { type: 'ADJUST/UP', payload: 1 });
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------
|
||||
|
||||
interface TypedState {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user