Simple use of typescript class combined with interface

1. Inheritance extends between interfaces

2. Use implements in combination with interfaces

interface Radio{
    switchRadio(trigger:boolean):void
}
interface Battery{
    checkBatteryStatus():void
}
//接口继承extends
interface RadioWithBattery extends Radio{
    checkBatteryStatus():void
}
//接口接合类implements
class Cellphone implements Radio{
    switchRadio(trigger:boolean){}
}
//接口接合类implements
class Cellphone2 implements RadioWithBattery{
    switchRadio(trigger:boolean){}
    checkBatteryStatus(){}
} 

Guess you like

Origin blog.csdn.net/u011200562/article/details/125100595