I upgraded lodash library from (v 2.4.1 to 4.17.15) and types/lodash(v 3.10.1 to 4.14.136) for an Angular JS project. I'm getting error for _.find after upgrade. Error statement
:Argument of type '{ 'Id': any; }' is not assignable to parameter of type 'ListIteratorTypeGuard<{}, IdModel>'.
this.search = _.find<{}, IdModel>(this.Idlist, {'Id': Id});
How can we convert it to ListIteratorTypeGuard? I'm not to find any solution. Kindly help if anyone knows how to resolve it.
If you want to enforce partial check of shorthand object, this should help.
type IdModel = { id: number, foo: string }; const list: Array<IdModel> = [{ id: 1, foo: 'test'}]; find<IdModel>(list, { id: 1});But most of the time you shouldn't specify generic params and use default inferred params instead