Type for passing a class?

Topics: General
Jul 19, 2013 at 12:53 PM
If I want to pass a class as a function, what type should I specify?

E.g.
class FooController {
  description = "A foo";
}

interface IStateConfig {
  name: string;
  controller: ????;
}

var fooConfig = { name: "foo", controller: FooController };
Coordinator
Jul 22, 2013 at 2:07 PM
Do you want to say the type of the class itself, rather than an instance of that class?

If so, we've added support for using 'typeof' at the type level in 0.9.1 to give you an easy way to do this. Otherwise, you'd have to type it out by hand:
interface ControllerClass {
   new() : FooController;
}
Jul 23, 2013 at 5:21 PM
I want to pass the Function that the class is compiled to. That interface looks like it will work, though.