I use typescript and react.
Loop through ISerch's sampleQuery, dammyQuery, foodQuery, and groupQuery with items.
I get the following error at save[i].query.
tsError
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'ISearch'.
No index signature with a parameter of type 'string' was found on type 'ISearch'.
interface ISearch {
test: string;
sampleQuery: { id: number; query: string };
dammyQuery: { id: number; query: string };
foodQuery: { id: number; query: string };
groupQuery: { id: number; query: string };
}
const searchText = (save: ISearch) => {
const items = ['sampleQuery', 'dammyQuery', 'foodQuery', 'groupQuery'];
let text = '';
items.map((i) => {
if (save[i].query != '') {
text = text.concat(save[i].query + ',');
}
});
return text;
};