I have the following object.
type Test = {
0: number[];
1: number[];
};
There will always be 2 keys named '0' and '1' in the object.
I want to iterate each key in the object and print the number in the value.
const logEveryItem = (test: Test): void => {
for (let key in test) {
test[key].forEach((i: number) => console.log(i));
}
};
But test[key] from the 3rd line, TypeScript gives the following error.
TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Test'. No index signature with a parameter of type 'string' was found on type 'Test'.
How should I fix this issue?