I am encountering an issue while attempting to loop through a complex object using ngFor and the keyvalue pipe. When I try to pass the key as an argument to a function within a component rendered inside the ngFor loop, TypeScript raises an error stating "Argument of type unknown is not assignable to parameter of type string".
<div *ngFor="let item of items | keyvalue">
<component [onItemUpdate]="onItemUpdate(item.key)"></component>
</div>
Although item.key should always be a string, TypeScript is interpreting it as unknown. How can this problem be properly addressed?
I have contemplated converting the object into an array as a workaround, but that does not address the root issue, which appears to originate from TypeScript itself. Is there a method to specify a type for the key in the keyvalue pipe?