interface IClassNameObject { [ index ] : boolean | undefined ; } const arr = [ ] ; type Name = string | IClassNameObject | undefined | null ; const transformObjToArr = ( name ) => Object . entries ( name ) . filter ( entry => entry [ 1 ] ) . map ( ( [ key ] ) => key ) ; const classNames = ( ... names ) => ( names || [ ] ) . reduce ( ( arr , name ) => { if ( ! name ) { return arr ; } if ( typeof name === 'string' ) { return arr . concat ( name ) ; } return arr . concat ( transformObjToArr ( name ) ) ; } , arr ) . join ( ' ' ) ; export default classNames ;