TypeScript 基本继承

示例

class Car {
    public position: number = 0;
    protected speed: number = 42;
    
    move() {
       this.position+= this.speed;
    }
}  

class SelfDrivingCar extends Car {

    move() {
        // 开始四处走动:-)
        super.move();
        super.move();
    }
}

本示例说明如何Car使用extends关键字创建该类的非常简单的子类。的SelfDrivingCar类重写move()方法和用途使用基类FPGA实现super。