TypeScript 代码(来自 https://lodash.com/docs#chain):
var users = [
{ 'user': 'barney', 'age': 36 },
{ 'user': 'fred', 'age': 40 },
{ 'user': 'pebbles', 'age': 1 }
];
var youngest = _.chain(users)
.sortBy('age')
.map(function(chr) {
return chr.user + ' is ' + chr.age;
})
.first()
.value();
tsc 编译器投诉:
error TS2339: Property 'sortBy' does not exist on type 'LoDashExplicitArrayWrapper<{ 'user': string; 'age': number; }>'.
pluck
也会发生同样的情况
是的,我正在研究它,如果您编写了哪些方法对您很有趣,我会先添加它们。
通过#6600:+1:
error TS2339: Property 'first' does not exist on type 'LoDashExplicitArrayWrapper<string>'.
@joe-chung 是的,模块定义中存在一些问题,它们现在很难添加签名first
(以及其他一些方法)
Property 'some' does not exist on type 'LodashArrayWrapper<any[]>'
@thakursagar接口LodashArrayWrapper
在lodash
的定义中长期不存在。 请检查您是否使用了最新版本的定义。 方法some
已经可以正常工作了。
你想让我在 LoDashExplicitArrayWrapper 中提交 _.reduce 的 PR 吗? 这对我们很有帮助
@gamebox是的,请添加 _.reduce,它肯定丢失了。
也需要_.uniqBy
还有_.flattenDepth()
和_.sort
和 _.split
_.flatMap
@chrootsu _.update
和_.updateWith
请:)
“LoDashStatic”类型不存在属性“mean”。
请添加_(x).split
同样的问题: Property 'split' does not exist on type 'LoDashExplicitWrapper<string>'
lodash 版本:3.10.1
Typings.json 依赖项:
"lodash": "registry:dt/lodash#3.10.0+20160802150749"
_.keyBy
似乎也不见了
_.findWhere 也不见了。 你能不能也添加这个...
_.assign 原样
_.flatMapDeep好吗? :)
LoDashExplicitArrayWrapper 上的 _.max
接口 LoDashExplicitArrayWrapper
/**
* @see _.max
*/
最大限度(
迭代对象:ListIterator
): LoDashExplicitWrapper
/**
* <strong i="17">@see</strong> _.max
*/
max(iteratee: string): LoDashExplicitWrapper<number>;
/**
* <strong i="18">@see</strong> _.max
*/
max(): LoDashExplicitWrapper<number>;
/**
* <strong i="19">@see</strong> _.max
*/
max(iteratee: Dictionary<{}>): LoDashExplicitWrapper<number>;
}
不知道为什么这是关闭的......类型中似乎缺少一堆方法(对我来说是_.uniqWith
)
和_.find
双方Property 'find' does not exist on type 'LoDashExplicitObjectWrapper<{}>'.
和Property 'find' does not exist on type 'LoDashExplicitArrayWrapper<{}[]>'
和 _.pairs
Property 'pairs' does not exist on type 'LoDashStatic'.
_.include 也是
_.也分
_.chain 之后发生的任何事情都会出现此错误,请帮助修复它@chrootsu @rbcasperson
_.地图也...
这个问题应该重新打开。
我检查了上面的评论,这些似乎仍然缺失:
_.divide();
_.include();
_.pairs();
这个错误应该重新打开,因为很多方法(上面提到的)仍然没有正确的类型。
也缺少变换,
由其他人在此处单独报告 #14748
这会很快得到解决吗?
有解决办法吗?
解决方法可能是这样的:
(lodash.chain(stuff).pickBy(lodash.isArray) as any).transform(transformFunction, []).value();
_.mapValues() 在 UnderscoreStatic 上不存在。 lodash 中缺少此方法请更新。
似乎 _mapValues 不包含在链中,而是独立工作
“LoDashImplicitArrayWrapper”类型上不存在属性“keys”
“LoDashImplicitArrayWrapper<...>”类型中缺少属性“length”
“LoDashImplicitObjectWrapper”类型上不存在属性“differenceWith”
请确保您在链的末端调用https://lodash.com/docs/#prototype -value
_.times 请
_.请分区
_.cond 请
_.下一个也请
_.upperCase 和 _.deburr 请
链(blabla)。mapValues()......
tslint 错误的结果Property 'mapValues' does not exist on type 'LoDashExplicitObjectWrapper<{}>'.
Opps... lodash 中不存在缺少的方法。
这几乎有效,但 .pickBy 也受此问题的影响!
(lodash.chain(stuff).pickBy(lodash.isArray) as any).transform(transformFunction, []).value();
_.uniq请用
我们有什么办法可以自己解决这个问题吗?
这个线程是几年前的,仍然有不起作用的功能!
@charlesr1971我也有_.uniqWith
,似乎该函数仍然有效,但接口尚未定义。
最有用的评论
解决方法可能是这样的: