I am attempting to retrieve the keys from an object of type FilterType
Here is the structure -
export interface FilterType {
name?: string[];
status?: string[];
brand?: string[];
categoryAndColour?: {
[category: string]: string[];
};
rating?: string[];
}
Here is the object -
const newState: FilterType = { ...state };
I am trying to create a function that eliminates all keys from newState, but I encounter errors when attempting to iterate through the object using map or for..in loops.
This is what I have been working on -
for (var key in newState){
delete newState[key];
}
return newState;
However, I keep receiving the error message
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type
And
No index signature with a parameter of type 'string' was found on type
How can I go about solving this issue?