I've been googling for hours, but can't wrap my head around this issue..
I have an interface:
interface Alert {
uuid: string,
city: string,
address: number
}
and I would like to itterate over a object, which is for sure compliant with this interface:
const alerts: Alert[] = response.from.api.alerts
now when I try to do something like this I get an error in ts compiler:
for (const alert of alerts) {
for(const field in alert) {
// this shows an error: Element implicitly has an 'any' type... ts(7053)
console.log(alert[field])
}
}
what's the correct way of accesing value of alert object?
should I use a type guard or something similar?
how can I declare to typescript that field is a keyof of alert?
should I disable the noImplicitAny flag -> is this considered "best practice"?
I know this question has been asked many times, but none of the answers helped me..
Thx for any help!