I encountered the following type error (TypeScript - 3.7.5).
Error TS2345: Argument of type '(priority1: number, priority2: number) => number' is not assignable to parameter of type '(a: unknown, b: unknown) => number'. Types of parameters 'priority1' and 'a' are incompatible. Type 'unknown' is not assignable to type 'number'.
Here is the code snippet:
public updatePriorities() {
const priorities = this.fetchedData.map((id: IList) => id.priority);
const uniquePriorities = [...new Set(priorities)];
uniquePriorities.sort((priority1: number, priority2: number) => priority1 - priority2);
const updatedPriorities = uniquePriorities.map((priority: number, index: number) => {
return index + 1;
});
uniquePriorities.forEach((id: number, index: number) => {
this.fetchedData.forEach((id1: IList) => {
if (id1.priority === id) {
id1.priority = updatedPriorities[index];
}
});
});
}