export interface NormMap { readonly [ key ] : NormObj ; } export type NormKey = string ; export type NormFieldValue = NormKey | string | boolean | number | null | NormFieldValueArray ; export interface NormFieldValueArray extends ReadonlyArray < NormFieldValue > { } export interface NormObj { readonly [ field ] : null | NormFieldValue ; } param normMap param newNormMap export function merge ( normMap , newNormMap ) { const updatedNormMap = Object . keys ( newNormMap ) . reduce ( ( stateSoFar , current ) => { const newNormObj = { ... ( normMap [ current ] || { } ) , ... newNormMap [ current ] } ; stateSoFar [ current ] = newNormObj ; return stateSoFar ; } , { } as { [ key ] : any ; } ) ; return { ... normMap , ... updatedNormMap } ; }