Extending vs. implementing a pure abstract class in TypeScript

前端 未结 4 1599
清酒与你
清酒与你 2020-12-02 12:01

Suppose I have a pure abstract class (that is, an abstract class without any implementation):

abstract class A {
    abstract m(): void;
}

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 12:48

    In the example of extends that you give you don't actually add anything new to the class. So it is extended by nothing. Although extending by nothing is valid Typescript it would seem to me that in this case 'implements' would be more appropriate. But at the end of the day they are equivalent.

提交回复
热议问题