title: Check if an object is a type of a generic type in Typescript
body: <p>I understand that TypeScript works as static type checker that transpiles to Javascript. </p>
  
  <p>So if I want to do something like the following, is there any workaround?</p>
  
  <pre><code>const resolve = &lt;T&gt;(map): T =&gt; {
      for (const value of map) {
          if (value instanceof T) {
              return &lt;T&gt; value;
          }
      }
  
      return null;
  };
  
  const map = [new A(), new B()];
  const a = resolve&lt;A&gt;(map);
  const b = resolve&lt;B&gt;(map);
  </code></pre>