📜  非抽象类不实现继承的抽象成员打字稿代码示例

📅  最后修改于: 2022-03-11 14:48:34.706000             🧑  作者: Mango

代码示例1
// You need to mark fields and methods that are not implemented as abstract
abstract class AbstractService {
    abstract someMethod(): Observable
}

// This will also force implementing classes to actually implement the methods:

// Error: Non-abstract class 'Service' does not implement inherited abstract member 'someMethod' from class 'AbstractService'
class Service extends AbstractService{}

// ok, methods is implemented
class OkService extends AbstractService {
    someMethod() {
        throw new Error("Method not implemented.");
    }
}