title: Function to get object from list of implementations in class by type of implementation. (typescript generics)
body: <p>I have a list of Components in a class Entity. These components extend the interface <code>Component</code>.</p>
  <pre><code>class Entity {
    ...
    const components: Component[] = [];
    ...
  }
  </code></pre>
  <p>Where specific components implements the interface Component</p>
  <pre><code>class SpecificComponent0 implements Component { ... }
  </code></pre>
  <p>Now I want to query the entity instance <code>e</code> and get a component if it matches the type fed into the query, something like this:</p>
  <pre><code>const specificComponent0 = e.getSpecificComponent&lt;SpecificComponentClass0&gt;();
  </code></pre>
  <p>Or perhaps like this</p>
  <pre><code>const specificComponent0 = e.getSpecificComponent(instanceof SpecificComponentClass0)
  </code></pre>
  <p>But I can't seem to figure out a way to do it in the entity's <code>get</code> function.</p>