File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
packages/node_modules/overmind/src/config Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -110,8 +110,20 @@ export function merge(...configurations: IConfiguration[]): IConfiguration {
110110 [ ] as any [ ]
111111 )
112112
113- return configurations . reduce (
113+ const reducedConfigurations = configurations . reduce (
114114 ( aggr , config ) => {
115+ const stateDuplicates = aggr . state ? Object . keys ( aggr . state ) . some ( key => config . state ? Object . keys ( config . state ) . includes ( key ) : false ) : false ;
116+ const actionsDuplicates = aggr . actions ? Object . keys ( aggr . actions ) . some ( key => config . actions ? Object . keys ( config . actions ) . includes ( key ) : false ) : false ;
117+ const effectsDuplicates = aggr . effects ? Object . keys ( aggr . effects ) . some ( key => config . effects ? Object . keys ( config . effects ) . includes ( key ) : false ) : false ;
118+ if ( stateDuplicates ) {
119+ throw new Error ( "Merge conflict: at least one state definition contains a duplicate key" )
120+ }
121+ if ( actionsDuplicates ) {
122+ throw new Error ( "Merge conflict: at least one actions definition contains a duplicate key" )
123+ }
124+ if ( effectsDuplicates ) {
125+ throw new Error ( "Merge conflict: at least one effects definition contains a duplicate key" )
126+ }
115127 return {
116128 onInitialize : aggr . onInitialize ,
117129 state : {
@@ -138,6 +150,7 @@ export function merge(...configurations: IConfiguration[]): IConfiguration {
138150 actions : { } ,
139151 }
140152 )
153+ return reducedConfigurations
141154}
142155
143156/*
You can’t perform that action at this time.
0 commit comments