Understanding Constructor Interfaces in typescript
<p>I am new to typescript and I am stuck in understanding constructor interfaces and the way they are type checked. Here is a snippet from docs:</p>

<pre><code>interface ClockConstructor {
    new (hour: number, minute: number): ClockInterface;
}
interface ClockInterface {
    tick();
}

function createClock(ctor: ClockConstructor, hour: number, minute: number): ClockInterface {
    return new ctor(hour, minute);
}

class DigitalClock implements ClockInterface {
    constructor(h: number, m: number) { }
    tick() {
        console.log("beep beep");
    }
}
class AnalogClock implements ClockInterface {
    constructor(h: number, m: number) { }
    tick() {
        console.log("tick tock");
    }
}

let digital = createClock(DigitalClock, 12, 17);
let analog = createClock(AnalogClock, 7, 32);
</code></pre>

<p>Here is what doc says about the above code:</p>

<blockquote>
  <p>Because createClock’s first parameter is of type ClockConstructor, in
  createClock(AnalogClock, 7, 32), it checks that AnalogClock has the
  correct constructor signature.</p>
</blockquote>

<p>Now this essentially means that DigitalClock class or AnalogClock classes have the type defined by ClockConstructor interface. How? It's a class and interface is describing a constructor.</p>

<p>Any takers please?</p>