title: How can I make Typescript understand that undefined could be a valid value here?
body: <p>I have a generic function, which is at some point zips a collection of items specified by generic type constraint:</p>
  <pre><code>import { zip } from 'lodash'
  
  function someFunc&lt;TResult&gt;() {
      // Funciton body omitted
      for (const [result, resolver] of zip(results, resolvers)) {
          if (!resolver) { throw new Error(`long error message`) }
          resolver(result)
      }
  }
  </code></pre>
  <p>And, unsurprisingly, I get the following error:</p>
  <blockquote>
  <p>Argument of type 'TResult | undefined' is not assignable to parameter
  of type 'TResult | PromiseLike'.   Type 'undefined' is not
  assignable to type 'TResult | PromiseLike'.</p>
  </blockquote>
  <p>Which is absolutely logical and helpful in 99% of cases. Usually, I'd just add a check that throws an error if it's undefined, right next to the check for <code>resolver</code>.</p>
  <p>However, I use this function with <code>void</code> parameter type, and <code>undefined</code> <strong>is</strong> assignable to <code>void</code>. How do I implement a runtime check that handles this case properly?</p>