any任意类型
void函数没有返回值数组
三、只读属性readonly
readonly数组能够被修改函数
四、额外的属性检查
as X 鸭子模型(不可靠,由于内部引不到,没啥用)this
对象从新赋值spa
字符串索引签名code
[propName:string]:any
四、函数类型对象
(x:string):boolean函数的参数类型和返回值类型
六、可索引的类型blog
七、类类型
实现接口
implements(以前有提到过,这里就不作解释了)继承
class Person { //成员变量 name: string //构造函数 constructor(name: string) { this.name=name } //成员函数 eat():void { console.log(this.name) } } class Student extends Person{ id: number; constructor(name:string,id:number) { super(name) } study() { console.log(this.id) } } const person = new Person("hou") console.log(person.name) person.eat() const student = new Student("hh",4) console.log(student.name) console.log(student.id)