Inheritance 强制派生到类的构造函数具有预定义的签名

Inheritance 强制派生到类的构造函数具有预定义的签名,inheritance,typescript1.5,Inheritance,Typescript1.5,在typescript中,是否可以强制所有派生类都有一个具有预定义签名的构造函数 如果父类的构造函数需要一些参数,开发人员将被迫使用超级构造函数传递这些参数: class Base { constructor(a : string, b : string) { // ... } } class Derived extends Base { constructor(a : string, b : string) { super(a,b);

在typescript中,是否可以强制所有派生类都有一个具有预定义签名的构造函数

如果父类的构造函数需要一些参数,开发人员将被迫使用超级构造函数传递这些参数:

class Base {
    constructor(a : string, b : string) {
        // ...
    }
}

class Derived extends Base {
    constructor(a : string, b : string) {
        super(a,b); // Error if super is not invoked
    }
}
如果开发人员没有显式声明
派生的
类构造函数,则在创建实例时会出现错误: