代码如下。
function inspect(item: { label: string } | {}) {
if (item.label) { //error
console.log("inspect jingo");
}
}
我得到的错误是 The property "label" does not exist in the type "{} | {label: string;}".The property "label" does not exist in the type "{}".
我是 typescript 新手。怎样声明 item 能接受空对象或 {label: string}。