I want to use this generic helper function to create form data:
function createFormData(data: any): FormData {
const formData = new FormData();
for (const key in data) {
formData.append(key, data[key]);
}
return formData;
}
But the ESLint gives me an unexpected any
warning.
When I change the parameter type any
to object
it shows me the following error message for data[key]
:
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. No index signature with a parameter of type 'string' was found on type '{}'
How can I fix my code here in order that no error messages or warnings are shown (without just turning off the linter)?