1 //接口扩展:接口可以继承接口 2 3 4 // interface Animal{ 5 6 // eat():void; 7 // } 8 9 // interface Person extends Animal{ 10 11 // work():void; 12 // } 13 14 // class Web implements Person{ 15 16 // public name:string; 17 // constructor(name:string){ 18 // this.name=name; 19 // } 20 21 // eat(){ 22 23 // console.log(this.name+'喜欢吃馒头') 24 // } 25 // work(){ 26 27 // console.log(this.name+'写代码'); 28 // } 29 30 // } 31 32 // var w=new Web('小李'); 33 34 // w.eat(); 35 36 37 38 39 40 41 42 43 44 45 46 47 interface Animal{ 48 49 eat():void; 50 } 51 52 interface Person extends Animal{ 53 54 work():void; 55 } 56 57 58 class Programmer{ 59 60 public name:string; 61 constructor(name:string){ 62 this.name=name; 63 } 64 65 coding(code:string){ 66 67 console.log(this.name+code) 68 } 69 } 70 71 72 class Web extends Programmer implements Person{ 73 74 constructor(name:string){ 75 super(name) 76 } 77 eat(){ 78 79 console.log(this.name+'喜欢吃馒头') 80 } 81 work(){ 82 83 console.log(this.name+'写代码'); 84 } 85 86 } 87 88 var w=new Web('小李'); 89 90 // w.eat(); 91 92 w.coding('写ts代码');