facing Unexpected nullable boolean value in conditional when compiled via lintin

Viewed 22

I have customized Accordion as FC. I have to remove Lintin errors, out of which I am facing Unexpected nullable boolean value in conditional. Please handle the nullish case explicitly

 const CustomizedAccordions: React.FC<IAccordionProps> = ({ items, theme, className, varient, ...props }) => {
  const [accordions, setAccordions] = React.useState(items)
  const handleChange = (
    event: any,
    key: string,
    onClose?: (event: any, e: string) => void,
    onOpen?: (event: any, e: string) => void
  ) => {
    const updated = accordions.map(e => {
      if (e.key === key) {
        if (e.isExpanded) {    // here giving error Unexpected nullable boolean value in 
                               //conditional. Please handle the nullish case explicitly
          onClose?.(event, e.key)
        } else {
          onOpen?.(event, e.key)
        }
        return {
          ...e,
          isExpanded: e.key === key && !e.isExpanded
        }
      }
      return e
    })
    setAccordions(updated)
  }

I tried to check e explicitly as null, undefined, nullish coalescing character.

Even this also didnt helped

 if (e !== null && e !== undefined && e.isExpanded) {
          onClose?.(event, e.key)
        } else {
          onOpen?.(event, e.key)
        }
0 Answers
Related