【发布时间】:2018-11-24 14:18:19
【问题描述】:
我得到的错误是 'LoDashExplicitWrapper<string[]>' is not assignable to type 'string[]'. Property 'length' is missing in type 'LoDashExplicitWrapper<string[]>'. 使用 lodash v4.17.10
我有一个对象数组,我正在尝试获取一个数组,该数组只包含每个对象的属性的唯一值。
代码:
let carMakes: string[]
const inventory = [
{ make: "ford", model: "Focus" },
{ make: "ford", model: "F-150" },
{ make: "chevy", model: "Camaro" }
carMakes = _.chain(inventory)
.map('make')
.uniq()
我有什么办法可以通过链接来完成这项工作,因为这看起来像是一个不错的干净解决方案,尽管它不起作用(在我的 Angular 项目中)
【问题讨论】:
标签: arrays typescript unique lodash