0

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Object'. No index signature with parameter of type 'string' was found on type 'Object'.

(Parameter) element:Object

tranform(items: Object[], searchString: string):Object[]{
 if(!items || !searchString) {
  return items; 
 }
 return items.filter((item: Object) => this.applyFilter(item, searchString));
}
applyFilter(element: Object, searchString: string): boolean{
                             
  for(var key in element){

   if(!element.hasOwnProperty(key)) continue;

    var obj =element[key]; // error getting here

   //code stuff
  }

}

I have tried below code changed to:-

applyFilter(element: Object) to 
applyFilter(element: {[key: string]:string}
return items.filter((item: Object) => this.applyFilter(item, searchString)); // getting error at `item`

applyFilter(element: {[key: string]:string}, searchString: string): boolean{
}

How to resolve this issue

User0777
  • 21
  • 3

0 Answers0