Recently I started working with TypeScript and encountered an issue while trying to eliminate duplicate objects based on a specific property, which in my case is the ID. Even though I attempted to use the filter method, I couldn't achieve the desired outcome. I've shared my code below. Can someone please provide some guidance? The list contains instances of an employee type, and I have defined a model class for employee. Since there may be duplicates IDs due to erroneous data, I need to find a way to remove these duplicates from the list before displaying it on the UI.
I also attempted to convert it to a set but unfortunately that approach didn't yield the expected results.
ids : Employee[] = new Array<Employee>();
this.list.filter((this.list=> ids.includes(this.list.idPk) ? false : ids.push(this.list.idPk));