title: How to type an array with classes in TypeScript?
body: <p>I have an app that initializes by running its method <code>.init(params)</code> like this:</p>
  
  <pre><code>app.init([TopBar, StatusBar, MainArea]);
  </code></pre>
  
  <p>Where <code>TopBar</code>, <code>StatusBar</code> and <code>MainArea</code> are classes, not instances of classes. Each of these classes implements the same interface <code>IComponent</code>.</p>
  
  <p>I want to instantiate objects from the passed classes in the <code>.init(params)</code> method, like this:</p>
  
  <pre><code>init(params: IComponent[]): void {
      params.map(function (component) {
          let comp = new component();
          this.components[comp.constructor.name] = comp;
      }, this);
  </code></pre>
  
  <p>The issue is that as these are not instance, TypeScript doesn't know their types and throws an error:</p>
  
  <blockquote>
    <p>error TS2345: Argument of type '(typeof TopBar | typeof StatusBar |
    typeof MainArea)[]' is not assignable to parameter of type
    'IComponent[]'.</p>
  </blockquote>
  
  <p>How do I fix the code so that I could pass an array of classes that implement some interface to a method?</p>