interface LabeledValue {
label: string;
}
function printLabel(labeledObj: LabeledValue) {
console.log(labeledObj.label);
}
let myObj = { size: 10, label: "Size 10 Object" };
// 通过
printLabel(myObj);
// 报错,字面量对象会有额外的类型检查
printLabel({ size: 10, label: "Size 10 Object" })