Typescript编译错误属性';一些';不存在于类型';洛达沙雷说唱歌手<;任何[]>';
我正在尝试在我的typescript程序中使用lodash来执行以下操作:Typescript编译错误属性';一些';不存在于类型';洛达沙雷说唱歌手<;任何[]>';,typescript,lodash,Typescript,Lodash,我正在尝试在我的typescript程序中使用lodash来执行以下操作: var atLeastOneCategoryMissingEntities = _(this.list) .pluck("items") .map((m:any) => { return _.pluck(m, "id"); }) .some((arr) => {
var atLeastOneCategoryMissingEntities = _(this.list)
.pluck("items")
.map((m:any) => {
return _.pluck(m, "id");
})
.some((arr) => {
var val = _.difference(arr, this.anotherList);
return val.length === arr.length;
});
list:[
{
category:{
name: "",
id:""
},
items:[{
name:"",
id:""
}]
}
]
另一个列表是字符串数组
我得到一个编译错误“属性'some'在类型'LodashArrayRapper'上不存在。”
lodash的Typescript定义不允许在类型“LodashArrayRapper”上使用。某些。因此,使用.value
将其转换为数组,然后您可以使用。其中一些,typescript编译器将不再抱怨
var atLeastOneCategoryMissingEntities = _(this.list)
.pluck("items")
.map((m:any) => {
return _.pluck(m, "id");
})
.value()
.some((arr) => {
var val = _.difference(arr, this.anotherList);
return val.length === arr.length;
});
list:[
{
category:{
name: "",
id:""
},
items:[{
name:"",
id:""
}]
}
]