@@ -3,7 +3,7 @@ import { Iterable, Map, fromJS } from 'immutable';
33import { ReduxAction , CreateReducerArgs } from './interfaces' ;
44
55const defaultArgs :CreateReducerArgs = {
6- initialState : { }
6+ actions : [ ]
77} ;
88
99/**
@@ -17,12 +17,12 @@ export function createReducer(args: CreateReducerArgs = defaultArgs) {
1717let { initialState, actions} = args ;
1818
1919if ( ! actions ) {
20- throw Error ( `Shorthand reducer should have {actions} property specified, but received: ${ actions } .` ) ;
20+ throw Error ( `Shorthand reducer should have {actions} property specified.` ) ;
2121}
2222
23- return ( state :Object , dispatchedAction :ReduxAction ) => {
23+ return ( state :Map < String , any > | Object , dispatchedAction :ReduxAction ) => {
2424/* Convert action to immutable */
25- const action = Map ( dispatchedAction ) ;
25+ const action = fromJS ( dispatchedAction ) ;
2626const dispatchedType = action . get ( 'type' ) ;
2727
2828/* Duplicate the state for further changes */
@@ -39,7 +39,11 @@ export function createReducer(args: CreateReducerArgs = defaultArgs) {
3939const isRegExp = ( expectedType instanceof RegExp ) ;
4040
4141/* Determine if dispatched action type is expected */
42- const shouldActionPass = isRegExp ?expectedType . test ( dispatchedType ) :expectedType . includes ( dispatchedType ) ;
42+ if ( expectedType instanceof RegExp ) {
43+ var shouldActionPass = expectedType . test ( dispatchedType ) ;
44+ } else {
45+ var shouldActionPass = expectedType . includes ( dispatchedType ) ;
46+ }
4347
4448/* Mutate the state once dispatched action type is expected */
4549if ( shouldActionPass ) {