Closed
Description
TypeScript Version: 2.7.0-dev.201xxxxx
Code
class Foo { constructor(a: string) { } }
let FooConstructor: { new(): Foo } = Foo;
Expected behavior:
Error message should tell the reason why constructor signatures are incompatible.
Actual behavior:
t.ts(3,5): error TS2322: Type 'typeof Foo' is not assignable to type 'new () => Foo'.
This is not particularly helpful, see comments below this answer, especially in comparison to the error message about incompatible methods:
let foo: { foo(a: string): void };
let foo2: { foo(): void };
foo2 = foo;
Type '{ foo(a: string): void; }' is not assignable to type '{ foo(): void; }'.
Types of property 'foo' are incompatible.
Type '(a: string) => void' is not assignable to type '() => void'.
So for constructor signature, ideally, the message could be
Type 'typeof Foo' is not assignable to type 'new () => Foo'.
Types of constructor signature are incompatible.
Type 'new(a: string) => Foo' is not assignable to type 'new() => Foo'.