title: Handling Events in TS - No overload
body: <p>I have the <strong>_onClick</strong> function, which listens to click or touch events depending on the device, so my event is MouseEvent or TouchEvent type.</p>
  
  <p>In useEffect, addEventListener complains with the message: No overload matches this call (2769).</p>
  
  <p>How can I properly write this down to avoid TS error?</p>
  
  <pre><code>const _onClick = (e: MouseEvent &amp; TouchEvent):void =&gt; {
    e.preventDefault();
  
    const positionX = (e.touches &amp;&amp; e.touches[0].pageX) || e.clientX;
  };
  
  
  useEffect(() =&gt; {
    if (tablet) {
      document.addEventListener('touchstart', _onClick);
    }
      document.addEventListener('mousedown', _onClick);
    }
  }, []);
  </code></pre>