【发布时间】:2020-08-07 03:12:58
【问题描述】:
我无法在我的应用上解决此错误。 本质上,我的界面设置如下:
interface skuInfo {
href: string
}
interface myObjectItem {
itemId: string
isFound: boolean
price: {
selling: number
}
images: {
sku: skuInfo[]
}
}
让我感到困惑的是myObjectItem.images.sku。
我有一个对象设置为:const exObj: myObjectItem。
当我尝试访问它的属性时:
exObj.images.sku[0].href,我收到以下错误:
Property 'href' does not exist on type 'object'
在我的 Visual Code 编辑器中,我可以看到它在访问对象数组时预填充了 href 属性,但 TS 仍在抱怨。
我错过了什么吗?
【问题讨论】:
标签: typescript typescript-typings typescript-types typescript-3.6