lodash/lodash-3.10.d.ts file in this repo and had problems.lodash/lodash-3.10.d.ts.Hello and thanks for the d.ts file for lodash.
Unfortunately I don't get the following piece of code (simplified) to compile:
let collection = {
a: '1',
b: '2',
c: ''
};
_.some(collection, (value, key) => {
return false;
});
=> Error:(186, 17) TS2345: Argument of type '{ a: string; b: string; c: string; }' is not assignable to parameter of type 'List<{}> | Dictionary<{}> | NumericDictionary<{}>'.
Type '{ a: string; b: string; c: string; }' is not assignable to type 'NumericDictionary<{}>'.
Index signature is missing in type '{ a: string; b: string; c: string; }'.
IMHO that should work according to their documentation (https://lodash.com/docs#some)
collection (Array|Object): The collection to iterate over.
The _.forEach method accepts an object (since it is declared as T extends {})
_.forEach(collection, (value, key) => {
// do something
});
forEach<T extends {}, TValue>(
collection: T,
iteratee?: ObjectIterator<TValue, any>,
thisArgs?: any
): T;
What is your opinion on that issue? Am I missing something?
Thanks for your help.
PS: I know that it used to compile with an very old version of the lodash.d.ts file (commitID: 9ce3cd4ded7536d40b8d65264ad729f442f5a052)
Hi, @pavax. Thanks for the bug report. Fixed by https://github.com/DefinitelyTyped/DefinitelyTyped/pull/8641 .
Hi @chrootsu. Thank you having a look at it and for your fix. I tested it and it work now fine for _.some
PS: I just realized that many other (collection-) commands (such as _.every, _.filter, _.includes) don't accept an object as an iterator. Should I create a new Issue for that in order to track it?
I think creating of new issues isn't required. The most likely I will recheck and fix them during the week.
Hi! So, is there some progress for this issue ? I have the same one
Same...
_.map(_.pickBy(_.map(this.participants, function(o){return o.sessions}), function(y){return y.mediaType}),'mediaType')
gives error:
Argument of type '{}' is not assignable to parameter of type 'List<{}> | Dictionary<{}> | NumericDictionary<{}>'.
Type '{}' is not assignable to type 'NumericDictionary<{}>'.
Any progress here?
I think this issue is resolve now.
Most helpful comment
Any progress here?