typescript automatic processing indefained to props

import { CSSProperties } from ‘react’

export interface buttonPropsInterface {
  text?: string
  styles?: CSSProperties
  color?: CSSProperties['backgroundColor']
  className?: string
}

When you specify that an attribute is not required, you have to check undefained or not each time. Can you tell me if anyone has managed to automate this process so that you don’t have to write checks each time?

I tried using generics but nothing worked out well

  • Please keep the question in english on this site.

    – 

  • ru.stackoverflow.com

    – 

  • 1

    Are you looking for nullish coalescing ?? and optional chaining ?. operators?

    – 

Leave a Comment