Note 415

Christian Kruse,

Currently I am working on a TypeScript project. During this project I wanted to give the TypeScript compiler the hint that I expect a class object as a parameter. I couldn't find something in the documentation. But since you can use expressions as type declaration I tried to use typeof:

class Bar {}
function foo(val: typeof Bar) {}

Surprisingly this works. Now after I knew what I had to look for I could find a hint in the documentation as well:

Next, we then use the class directly. Here we create a new variable called greeterMaker. This variable will hold the class itself, or said another way its constructor function. Here we use typeof Greeter, that is “give me the type of the Greeter class itself” rather than the instance type.

Maybe this saves you a few headaches.