I am currently facing a type issue in typescript:
I want to specify the type of variables in a destructuring assignment inside a for-of-loop, in order to be able to add properties to given variable.
However, if I want to specify types like this:
const exampleObject: any = {
key1: {
a: "Some value",
b: 42
},
key2: {
a: "Some other value",
b: 1337
}
};
for (const [key, value]: [string, any] of Object.entries(exampleObject)) {
value.c = 5;
};
eslint shows me this error:
The left-hand side of a 'for...of' statement cannot use a type annotation.
Hence, without being able to specify types, I receive this error:
Object is of type 'unknown'
on this line: value.c = 5;
Am I doing something wrong, or is there any way to annotate types here?