import { mergeWith } from 'lodash' ; import { Capabilities } from './types' ; export const mergeCapabilities = ( ... sources ) : Capabilities => mergeWith ( { } , ... sources , ( a , b ) => { if ( ( typeof a === 'boolean' && typeof b === 'object' ) || ( typeof a === 'object' && typeof b === 'boolean' ) ) { throw new Error ( `conflict trying to merge boolean with object` ) ; } if ( typeof a === 'boolean' && typeof b === 'boolean' && a !== b ) { throw new Error ( `conflict trying to merge booleans with different values` ) ; } } ) ;