title: Typescript: Pass generic class to function parameter
body: <p>I need to pass a <code>class reference</code> as a <code>function parameter</code> and invoke a <code>static method</code> on this class. In the future, I might need to create an instance of the class and added a constructor as example.</p>
  
  <p>I have it working without typings:</p>
  
  <pre><code>class Messages {
      getMessage(classRef: any): any {
         return classRef.getMessage()
       }
  }
  
  class myClassA {
      constructor(public id: number, public message: string) {}
      static getMessage(): string {
          return 'hello from class A';
      }
  }
  
  class myClassB {
      constructor(public id: number, public message: string) {}
      static getMessage(): string {
          return 'hello from class B';
      }
  }
  
  var messages = new Messages();
  var messageA = messages.getMessage(myClassA);
  var messageB = messages.getMessage(myClassB);
  
  console.log(messageA) // 'hello from class A'
  console.log(messageB) // 'hello from class B'
  </code></pre>
  
  <p>I am trying to type the class reference, possibly with generics but confused about how to go about this.</p>
  
  <p>I tried doing something along the lines of <code>getMessage&lt;C&gt;(classRef: {new(): C;}): any {}...</code> but none of that is working.</p>
  
  <p>Can someone please explain how I can pass a class reference properly? </p>