-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Error MessagesThe issue relates to error messagingThe issue relates to error messagingFix AvailableA PR has been opened for this issueA PR has been opened for this issueFixedA PR has been merged for this issueA PR has been merged for this issueGood First IssueWell scoped, documented and has the green lightWell scoped, documented and has the green lightHelp WantedYou can do thisYou can do this
Milestone
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'.
aluanhaddad and calexandrepcjr
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Error MessagesThe issue relates to error messagingThe issue relates to error messagingFix AvailableA PR has been opened for this issueA PR has been opened for this issueFixedA PR has been merged for this issueA PR has been merged for this issueGood First IssueWell scoped, documented and has the green lightWell scoped, documented and has the green lightHelp WantedYou can do thisYou can do this