类型注解123456789// jsfunction greeter(person) {}// tsfunction greeter(person: string) {} 接口1234567891011121314interface Person{ firstName: string, lastName: string}function greeter(person: Person) {}let user = { firstName: 'J', lastName: 'N'};// 内部结构兼容则兼容greeter(user); 类12345678910// 使用public可以自动创建该名称的属性class Student { fullName: String, constructor(public firstName: string, public lastName: string) { this.fullName = firstName+lastName; }}let user = new Student('J', 'N');