// 通常我们定义对象使用interface 注意是分号
interface IPerson {
name: string;
age: number;
sex: string;
}
let person3: IPerson = {
name: "张三",
age: 18,
sex: "男",
};
let person4: IPerson = {
name: "张三",
age: 18,
sex: "男",
// 对象字面量只能指定已知属性,并且“height”不在类型“IPerson”中
height: 170,
};
// 通常我们定义对象使用interface 注意是分号
interface IPerson {
name: string;
age: number;
sex: string;
}
let person3: IPerson = {
name: "张三",
age: 18,
sex: "男",
};
let person4: IPerson = {
name: "张三",
age: 18,
sex: "男",
// 对象字面量只能指定已知属性,并且“height”不在类型“IPerson”中
height: 170,
};