export type DeepStringObj = { [ key ] : string | DeepStringObj ; } ; export type StringObj = { [ key ] : string | undefined ; } ; const buildKey = ( base , curr ) => base ? `${ base }.${ curr }` : curr ; export const flatObject = ( object ) : StringObj => { const result = { } ; const iterate = ( item , currentKey ) => { Object . keys ( item ) . forEach ( ( key ) => { const value = item [ key ] ; if ( typeof value === 'object' ) iterate ( value , buildKey ( currentKey , key ) ) ; else result [ buildKey ( currentKey , key ) ] = value ; } ) ; } ; iterate ( object , '' ) ; return result ; } ;