类可以实现接口,使用关键字 implements,并将 interest 字段作为类的属性使用。
以下实例中 AgriLoan 类实现了 ILoan 接口
interface ILoan{
interest:string
}
class AgriLoan implements ILoan{
interest:string
rebate:string
constructor( interest:string, rebate:string){
this.interest=interest
this.rebate=rebate
}
}
var obj3=new AgriLoan('1',"2")
console.log(obj3.interest,obj3.rebate) // 1 2
https://www.runoob.com/typescript/ts-class.html