title: Typescript and useRef hook causing type error
body: <p>I made a custom Checkbox component to handle events differently, code below:</p>
  <pre><code>const DoubleClickCheckbox = ({ filter, handleDoubleClick, handleSingleClick }: DCCheckboxProps) =&gt; {
    const delay = 400;
    const timer = useRef(null);
  
    const classes = useStyles();
    const flags = useFlags();
  
    useEffect(() =&gt; {
      return () =&gt; {
        timer.current &amp;&amp; clearTimeout(timer.current);
      };
    }, []);
  
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    const onClick = (e) =&gt; {
      if (flags.csRequireFilters) {
        e.stopPropagation();
        handleSingleClick(filter);
        return;
      }
  
      switch (e.detail) {
        case 1:
          // eslint-disable-next-line @typescript-eslint/ban-ts-comment
          // @ts-ignore
          timer.current = setTimeout(() =&gt; {
            handleSingleClick(filter);
          }, delay);
          break;
        case 2:
          // eslint-disable-next-line @typescript-eslint/ban-ts-comment
          // @ts-ignore
          clearTimeout(timer.current);
          handleDoubleClick(filter);
          break;
        default:
          // eslint-disable-next-line @typescript-eslint/ban-ts-comment
          // @ts-ignore
          clearTimeout(timer.current);
          return;
      }
    };
  
    return (
      &lt;div className={classes.filter} onClick={onClick} onKeyDown={() =&gt; {}} role=&quot;button&quot; tabIndex={0}&gt;
        &lt;Checkbox
          label={filter.label}
          className={classes.checkbox_custom}
          checked={filter.selected}
          checkedIcon={filter.mandatory ? &lt;Icons.CheckboxDoubleClick /&gt; : &lt;Icons.CheckboxSingleClick /&gt;}
        /&gt;
      &lt;/div&gt;
    );
  };
  </code></pre>
  <p>I would like to dump my <code>eslint-disable-next-line @typescript-eslint/ban-ts-comment</code> and <code>ts-ignore</code>.</p>
  <p>If I rewrite my code it reads as below, I get a typescript error:</p>
  <pre><code>  case 1:
      timer.current = setTimeout(() =&gt; {
        handleSingleClick(filter);
      }, delay);
      break;
  </code></pre>
  <p>The error is: <code>Type 'Timeout' is not assignable to type 'null'.</code> I have tried various other tricks, for example: <code>const timer = useRef&lt;React.MutableRefObject&lt;ReturnType&lt;typeof setTimeout&gt;&gt;&gt;(null);</code>.</p>
  <p>It did not help either.</p>
  <p>Please advise</p>