title: Typescript debounce function not calling function passed as parameter
body: <p>I'm trying to write a <a href="https://stackoverflow.com/questions/24004791/can-someone-explain-the-debounce-function-in-javascript">debounce</a> function with <strong>typescript</strong>. </p>
  
  <p>I found an example of it in <a href="https://www.yceffort.kr/2019/10/14/debounce/" rel="noreferrer">here</a>. Code follows:</p>
  
  <pre><code>export function debounce&lt;Params extends any[]&gt;(
    func: (...args: Params) =&gt; any,
    timeout: number,
  ): (...args: Params) =&gt; void {
    let timer: NodeJS.Timeout
    return (...args: Params) =&gt; {
      clearTimeout(timer)
      timer = setTimeout(() =&gt; {
        func(...args)
      }, timeout)
    }
  }
  </code></pre>
  
  <p>Problem is:</p>
  
  <ul>
  <li>Function passed as a parameter is not getting called after the specified timeout</li>
  <li>I can't use lodash or any other external library because I'm trying to avoid adding new dependencies to this project.</li>
  </ul>
  
  <p>Thanks.</p>