-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix 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 issue
Milestone
Description
Search Terms
abstract derived class constructor signature error message
Suggestion
Currently the following code:
abstract class A { }
class B extends A {
constructor(a: string) {
super();
}
}
const b: typeof A = B;will give you the following error: Type 'typeof B' is not assignable to type 'typeof A'.
When you encountering this issue for the first time as a new typescript user, and you already have a bunch of code for both abstract and derived classes, it might be hard to track down what is causing the type error. So consider adding more specificity to the error message, smth like "Derived class should have the same constructor signature as a parent".
Use Cases
Currently error message is not clear enough.
Examples
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
vkrol
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix 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 issue