title: Shortest way to call possibly undefined function
body: <p>Coming from a background in C# the null-conditional operator allows you to call a function avoiding a possible null-reference exception like so:</p>
  <pre class="lang-cs prettyprint-override"><code>Func&lt;int&gt; someFunc = null;
  int? someInteger = someFunc?.Invoke();
  // someInteger == null
  </code></pre>
  <p>Given that Typescript has the &quot;optional chaining operator&quot; <code>.?</code> with very similar functionality I'm wondering if there's a way to do the same with a similarly concise piece of code. The best I can come up with is using a conditional expression:</p>
  <pre><code>let someFunc: (() =&gt; number) | undefined = undefined;
  let someNumber = someFunc !== undefined ? someFunc() : undefined;
  </code></pre>
  <p>Perhaps <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply" rel="noreferrer">apply</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call" rel="noreferrer">call</a> can be utilized somehow?</p>