<p dir="auto">I'm having an issue that foces me to rewrite the type of a function parameter to 'any' instead of 'typeof SomeSuperClass' because a subclass that extends that superclass, but has <em>another constructor signature</em> cannot be passed into that function anymore. Is this expected behavior? My intuition says no. I've read that it has to do with some Javascript function type check conflict because of the use of 'typeof', but currently I don't see another clean way to pass a class type as an argument in a function. without resolving to strings. And the use of 'typeof' seems to break when a subclass has another constructor signature.</p>
<p dir="auto">See code, where function foo(..) accepts the subclass with equal constructor signature, but rejects the other subclass which has another constructor signature:</p>
<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">1.7.5</p>
<p dir="auto"><strong>Code</strong></p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class Super {
    private a: number;
    constructor(a : number) {
        this.a = a;
    }
}

class SubSameConstructor extends Super {
    private b: number;
    constructor(a : number) {
        super(a);
        this.b = a;
    }
}

class SubDifferentConstructor extends Super {
    private b: number;
    constructor(a : number, b: number) {
        super(a);
        this.b = b;
    }
}

function foo(classParam: typeof Super) {
    console.log(classParam);
}

foo(SubSameConstructor); // works
foo(SubDifferentConstructor); // TS2345: Argument of type 'typeof SubDifferentConstructor' is not assignable to parameter of type 'typeof Base'."><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-smi">Super</span> <span class="pl-kos">{</span>
    <span class="pl-k">private</span> <span class="pl-c1">a</span>: <span class="pl-smi">number</span><span class="pl-kos">;</span>
    <span class="pl-en">constructor</span><span class="pl-kos">(</span><span class="pl-s1">a</span> : <span class="pl-smi">number</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">a</span> <span class="pl-c1">=</span> <span class="pl-s1">a</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-k">class</span> <span class="pl-smi">SubSameConstructor</span> <span class="pl-k">extends</span> <span class="pl-smi">Super</span> <span class="pl-kos">{</span>
    <span class="pl-k">private</span> <span class="pl-c1">b</span>: <span class="pl-smi">number</span><span class="pl-kos">;</span>
    <span class="pl-en">constructor</span><span class="pl-kos">(</span><span class="pl-s1">a</span> : <span class="pl-smi">number</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-smi">super</span><span class="pl-kos">(</span><span class="pl-s1">a</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">b</span> <span class="pl-c1">=</span> <span class="pl-s1">a</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-k">class</span> <span class="pl-smi">SubDifferentConstructor</span> <span class="pl-k">extends</span> <span class="pl-smi">Super</span> <span class="pl-kos">{</span>
    <span class="pl-k">private</span> <span class="pl-c1">b</span>: <span class="pl-smi">number</span><span class="pl-kos">;</span>
    <span class="pl-en">constructor</span><span class="pl-kos">(</span><span class="pl-s1">a</span> : <span class="pl-smi">number</span><span class="pl-kos">,</span> <span class="pl-s1">b</span>: <span class="pl-smi">number</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-smi">super</span><span class="pl-kos">(</span><span class="pl-s1">a</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">b</span> <span class="pl-c1">=</span> <span class="pl-s1">b</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-k">function</span> <span class="pl-en">foo</span><span class="pl-kos">(</span><span class="pl-s1">classParam</span>: <span class="pl-k">typeof</span> <span class="pl-smi">Super</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">classParam</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-en">foo</span><span class="pl-kos">(</span><span class="pl-smi">SubSameConstructor</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// works</span>
<span class="pl-en">foo</span><span class="pl-kos">(</span><span class="pl-smi">SubDifferentConstructor</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// TS2345: Argument of type 'typeof SubDifferentConstructor' is not assignable to parameter of type 'typeof Base'.</span></pre></div>
<p dir="auto"><strong>Expected behavior:</strong><br>
Being able to pass a subclass with different constructor signature into a function that accepts an argument of type 'typeof Super' to pass class types.</p>
<p dir="auto"><strong>Actual behavior:</strong><br>
The last function call does not compile.</p>
<p dir="auto">Currently we create <code class="notranslate">DocumentRegistry</code> <a href="https://github.com/Microsoft/TypeScript/blob/master/src/server/editorServices.ts#L1358">once per project</a> which means that we don't share anything between multiple open projects (because of that we can end up with multiple copies of i.e. <code class="notranslate">lib.d.ts</code>). We should consider using one instance of <code class="notranslate">DocumentRegistry</code> that will be utilized for all projects to remove this duplication.</p>