DefinitelyTyped/types/redux-immutable/redux-immutable-tests.ts
Kanitkorn Sujautra 29d283ca5c [redux-immutable] Upgrade type definition to support Redux v4 + Immutable v4 (#29334)
* [redux-immutable] Move the current version to v3 subfolder

* [redux-immutable] Copied v3 over to root and update it to v4
2018-10-08 10:21:41 -07:00

42 lines
1.4 KiB
TypeScript

import { combineReducers } from 'redux-immutable';
import { Map, List } from 'immutable';
import { AnyAction } from 'redux';
// Dummy State interface
interface State { };
/**
* Combine reducers should work with only one argument (a reducers object).
*/
combineReducers({});
combineReducers<State>({});
/**
* Combine reducers support reducer with custom action
*/
combineReducers<State, { type: string; payload: number | string}>({
reducerNumber: (state: number, action: { type: string; payload: number }) => {
switch(action.type) {
case 'multiply': return state * action.payload
default: return state
}
},
reducerString: (state: string, action: { type: string; payload: string }) => {
switch(action.type) {
case 'concat': return state.concat(action.payload)
default: return state
}
},
});
/**
* Combine reducers should accepts a function (getDefaultState()) as a second parameter, that returns an immutable Collection.Keyed collection.
*/
combineReducers<State, AnyAction, string>({}, () => { return Map<string, State>(); });
combineReducers<State, AnyAction, number>({}, () => { return Map<number, State>(); });
/**
* Combine reducers should accepts a function (getDefaultState()) as a second parameter, that returns an immutable Collection.Indexed collection.
*/
combineReducers<State>({}, () => { return List<State>(); });