title: Create typescript extension for array of particular class type
body: <p>I know that i can create a basic Array extension, something like this, which works on all arrays, no matter what the type is within that array.</p>
  
  <pre><code>export {};
  
  declare global {
      interface Array&lt;T&gt; {
          isEmpty(): boolean;
      }
  }
  
  // determines if an array is empty, or if the contents of the items in the array are empty
  Array.prototype.isEmpty = function() {
      if (this.length == 0) {
          return true;
      } else {
          return this.some((c) =&gt; c != null &amp;&amp; c != '');
      }
  };
  </code></pre>
  
  <p>But i would like to create an extension for an array that only contains a particular object?  I have tried this, but gives error</p>
  
  <pre><code>import { MyObject } from './my-object';
  
  export {};
  
  declare global {
      interface Array&lt;MyObject&gt; {
          isEmpty(): boolean;
      }
  }
  
  // determines if an array is empty, or if the contents of the items in the array are empty
  Array.prototype.isEmpty = function() {
      if (this.length == 0) {
          return true;
      } else {
          return this.some((c) =&gt; c != null &amp;&amp; c != '');
      }
  };
  </code></pre>
  
  <p>I have tried to find out by looking <a href="https://www.typescriptlang.org/docs/handbook/generics.html" rel="nofollow noreferrer">here</a> but i cannot seem to figure out the correct syntax.</p>
  
  <p>Any help much appreciated :)</p>