title: Generic Comparison in TypeScript
body: <p>I am currently reading up on Generic Comparison's in TypeScript. I get it that types are removed when transpiling from TypeScript to JavaScript so you can't compare two generic types.</p>
  <p>So this is a 3-part question.
  Question 1:  Can someone explain what <code>extends Array</code> does here?
  Question 2: I know when I console.log(c3), I get <code>[ '1', '2', '500', '600' ]</code> So when I call <code>concatenate(l1, l4)</code>, because <code>l1</code> and <code>l4</code> share the same ID and type, const <code>oneList</code> is created and then returned?
  Question 3: What is T1 doing?  Is it essentially the ID being used for <code>list1</code> and <code>list2</code>?</p>
  <pre><code>class IdentificatedGeneric&lt;S&gt; extends Array&lt;S&gt; {
      public id: string; // Enhancement of Array class
      public constructor(id: string) {
          super();
          this.id = id;
      }
  }
  function concatenate&lt;S, T1 extends IdentificatedGeneric&lt;S&gt;&gt;(list1: T1, list2: T1): T1 {
      if (list1.id === list2.id) { // Comparison to ensure from the same id, possible because both extends IdentificatedGeneric
          const oneList = [...list1, ...list2] as T1;
          return oneList;
      }
      throw Error(&quot;Must be the same id&quot;);
  }
  
  const l1 = new IdentificatedGeneric&lt;string&gt;(&quot;l1&quot;);
  const l2 = new IdentificatedGeneric&lt;string&gt;(&quot;l2&quot;);
  const l3 = new IdentificatedGeneric&lt;number&gt;(&quot;l1&quot;);
  const l4 = new IdentificatedGeneric&lt;string&gt;(&quot;l1&quot;);
  
  l1.push(&quot;1&quot;, &quot;2&quot;);
  l2.push(&quot;100&quot;, &quot;200&quot;);
  l3.push(5, 6);
  l4.push(&quot;500&quot;, &quot;600&quot;);
  
  const c3 = concatenate(l1, l4);
  console.log(c3);
  </code></pre>