Search code examples
angularlodashangular6

Lodash omit not working after angular migration to 6


I've this function working fine:

 SFcopy = _.omit(SFcopy, (objectValue: any, objectField: string): boolean => {
            return (
                !defaultSF.hasOwnProperty(objectField) ||
                _.isEqual(defaultSF[objectField], objectValue)
            );
         });

but when I updated angular to 6 the function stopped working and it shows me the following error that I do not know how to fix

ERROR in src/app/shared/search-filter.ts(1156,33): error TS2345: Argument of type '(objectValue: any, objectField: string) => boolean' is not assignable to parameter of type 'Many'. Type '(objectValue: any, objectField: string) => boolean' is not assignable to type 'PropertyKey[]'. Property 'includes' is missing in type '(objectValue: any, objectField: string) => boolean'.

enter image description here

LODASH version(update to the last version doesn't work):

"lodash": "^4.17.4",
"@types/lodash": "^4.14.62",

Can you help me to fix it?

Thank you.


Solution

  • _.omit was changed in Lodash 4. Now the predicate version is extracted and renamed to _.omitBy. Change it to _.omitBy and it should work as before.