import { ImageStyle, TextStyle, ViewStyle } from 'react-native'; type Style = ViewStyle | TextStyle | ImageStyle; type NullableStyle = Style | null | undefined; const isNil = (val: unknown) => val == null; const merge = (obj1: NullableStyle, obj2: NullableStyle) => obj2 == null ? obj1 : Object.keys(obj2).reduce((res, key) => (isNil(obj2[key]) ? res : { ...res, [key]: obj2[key] }), obj1); const composeStyles = (styles: NullableStyle[] = []): NullableStyle => styles.reduce(merge, {}); export default composeStyles;