title: Typescript - type to represent any class?
body: <p>What type should I use in typescript to represent any class?</p>
  
  <p>I'm trying to write a function that takes an array of classes and returns an array with different order.</p>
  
  <pre><code>function shuffle(classes: typeof Object[]) : typeof Object[] {
      return ...;
  }
  
  class A { }
  class B extends A { }
  class C extends B { }
  class D extends B { }
  suffle([A, B, C, D]);
  </code></pre>
  
  <blockquote>
    <p>Argument of type 'typeof A[]' is not assignable to parameter of type 'ObjectConstructor[]'.</p>
  </blockquote>
  
  <p>Then I've tried:</p>
  
  <pre><code>shuffle([typeof A, typeof B, typeof C, typeof D]);
  </code></pre>
  
  <blockquote>
    <p>error TS2345: Argument of type 'string[]' is not assignable to parameter of type 'ObjectConstructor[]'.
      Type 'string' is not assignable to type 'ObjectConstructor'.</p>
  </blockquote>
  
  <p>What's the right way? Generics? How? This doesn't work:</p>
  
  <pre><code>export function &lt;T extends typeof Object&gt; shuffle(classes: T[]) : T[]
  </code></pre>
  
  <p>This neither:</p>
  
  <pre><code>export function &lt;T extends Object&gt; sortClassesBySpeciality(classes: typeof T[]) : typeof T[]
  </code></pre>
  
  <p><strike>Also why <code>typeof (typeof A)</code> is <code>"string"</code> and <code>"" + typeof A</code> is <code>function</code>?</strike> Ok, got this, <code>typeof</code> has two very different meanings context of type definition and expression.</p>
  
  <p><em>(The ultimate goal is to sort the classes by level of <code>extends</code> from <code>Object</code>.)</em></p>