Definitelytyped: LoDashExplicitArrayWrapperに欠落しているいくつかのメソッドをLodash

作成日 2015年11月03日  ·  50コメント  ·  ソース: DefinitelyTyped/DefinitelyTyped

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でも起こります

最も参考になるコメント

回避策は次のようになります。

(lodash.chain(stuff).pickBy(lodash.isArray) as any).transform(transformFunction, []).value();

全てのコメント50件

はい、私はそれに取り組んでいます、そしてあなたがあなたにとって興味深いメソッドを書くなら、私はそれらを最初に追加します。

#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ええ、

_.uniqByも必要です

また_.flattenDepth()

および_.sort

および_.split

_.flatMapお願いします

@chrootsu _.update_.updateWithお願いします:)

プロパティ「mean」はタイプ「LoDashStatic」に存在しません。

_(x).splitを追加してください

同じ問題: Property 'split' does not exist on type 'LoDashExplicitWrapper<string>'

lodashバージョン:3.10.1

types.jsonの依存関係:
"lodash": "registry:dt/lodash#3.10.0+20160802150749"

_.keyByも欠落しているようです

_.findWhereもありません。 これも追加して頂けますか...

_.assignも同様です

_.flatMapDeepお願いしますか? :)

LoDashExplicitArrayWrapperの_.max

インターフェイスLoDashExplicitArrayWrapper{{
/ **
* @see _.max
* /
max(
iteratee: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の後に続くものはすべてこのエラーが発生しますが、plzはそれを修正するのに役立ちます@chrootsu @rbcasperson

_.mapも..。
この問題は再開する必要があります。

上記のコメントを確認しましたが、まだ欠落しているようです。

_.divide();
_.include();
_.pairs();

多くのメソッド(上記)にはまだ正しい入力がないため、このバグを再度開く必要があります。

また、変換もありません、
ここで他の誰かによって個別に報告された#14748
これはすぐに修正される予定ですか?
回避策はありますか?

回避策は次のようになります。

(lodash.chain(stuff).pickBy(lodash.isArray) as any).transform(transformFunction, []).value();

_.mapValues()はUnderscoreStaticに存在しません。 このメソッドはlodashから欠落しています。親切に更新してください。

_mapValuesはチェーンに含まれていないようですが、スタンドアロンとして機能しています

プロパティ 'keys'はタイプ 'LoDashImplicitArrayWrapperに存在しません'

プロパティ「長さ」がタイプ「LoDashImplicitArrayWrapper <...>」にありません

プロパティ 'differenceWith'はタイプ 'LoDashImplicitObjectWrapperに存在しません'。

チェーンの最後でhttps://lodash.com/docs/#prototype-valueを呼び出すようにしてください

_。回お願いします

_。パーティションをお願いします

_.condお願いします

_.nextもお願いします

_.upperCaseと_.deburrをお願いします

chain(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();

_.uniqWithお願いします

これを自分で修正する方法はありますか?

このスレッドは数年前のものであり、まだ機能しない関数があります!

@ charlesr1971 _.uniqWithも問題があります。関数はまだ機能しているようですが、インターフェイスはまだ定義されていません。

このページは役に立ちましたか?
0 / 5 - 0 評価