Closed
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.