I created a reusable component that takes a list of elements of the type any. He works on these elements and in the case of pressing the button returns the state of the list he got. I'm worried about losing typing in this case. Is this a safe solution? I would like the component to be reusable. Is it possible to dynamically cast from any type to a different type?
I tried to cast object in set Input() but it is not possible
export class ReusableTableComponent {
@Input() list: any[];
@Output() selectedItems: EventEmmiter = new EventEmmiter<any>;
selectedItemsList: any[] = [];
emitChanges() {
this.selectedItems.emit(this.selectedItemsList)}
}
The problem is, eventEmmiter is returning object type not specific type.