type ButtonProps = { children : string ; } ; type PrimaryButtonProps = { primary : boolean ; secondary ? : never ; destructive ? : never ; } ; type SecondaryButtonProps = { primary ? : never ; secondary : boolean ; destructive ? : never ; } ; type DestructiveButtonProps = { primary ? : never ; secondary ? : never ; destructive : boolean ; } ; const createClassNames = ( classes ) : string => { let classNames = '' ; for ( const [ key , value ] of Object . entries ( classes ) ) { if ( value ) classNames += key + ' ' ; } return classNames . trim ( ) ; } ; const Button = ( { children , primary = false , secondary = false , destructive = false } ) => { const classNames = createClassNames ( { primary , secondary , destructive } ) ; return < button className = { classNames } > { children } < /button>; } ; const Application = ( ) => { return ( < main > < Button primary > Primary < /Button> < Button secondary > Secondary < /Button> < Button destructive > Destructive < /Button> < /main>); } ; export default Application ;