I have a generic functional component in which I got the following code:
if(Array.isArray(entry[key as keyof T]) {
entry[key as keyof T].forEach((item: T) => { ... });
}
Where key is a variable string. The .forEach is red underlined with the following error message:
Property 'forEach' does not exist on type 'T[keyof T]'
even though I checked if the value is an array in the conditional statement. How do I work around this?