I'm curious about TypeScript and why the two function calls below result in different type checking outcomes. Can someone shed some light on this for me?
interface LabelledValue {
label: string;
}
function printLabel(labelledObj: LabelledValue) {
console.log(labelledObj.label);
}
var myObj = {size: 10, label: "Size 10 Object"};
//The type checking is successful with this call
**printLabel(myObj);**
//However, an error is flagged with this call stating "size does not exist in LabelledValue"
**printLabel({ size: 10, label: "Size 10 Object" });**
Thank you in advance.