title: How to determine a variable type in TypeScript?
body: <p>I have this logic,</p>
  
  <pre><code>.switchMap((data: ISearchModalPayload | number ) =&gt; {..... }
  </code></pre>
  
  <p>where <code>data</code> is either an interface object or a number.</p>
  
  <p>How can I determine the data type before I carry on with my routine?</p>
  
  <p>I tried the following, from this <a href="https://stackoverflow.com/a/541769/2157801">post</a>, but none worked:</p>
  
  <ul>
  <li><code>if (obj instanceof C) {}</code></li>
  <li><code>Object.getClass()</code></li>
  <li><code>.isInstance</code></li>
  </ul>