接口是用来描述对象性状的
interface School{ readonly type:String, //readonly表示只读,不可更改的属性 age:Number, adress?:String //?代表非必要 } let BeiDa:School={ type:'Univercity', age:100, adress:'beijing' }
接口是可以扩展的
Interface SchoolGrade extends School{ grade:String [xxx:String]:any //表示其它任意属性的任意值 } let sannianerban:SchoolGrade={ ...BeiDa, grade:'3年2班', guys:30, row:5, col:6 }
类型断言 (相当于类型强制转换)
let grade2:School=({ name:'QingHua', age:105, adress:'BeiJing', lessons:'高等数学' }) as School