Skip to content

Commit

Permalink
Type correctly uniqBy helper
Browse files Browse the repository at this point in the history
  • Loading branch information
dtrucs committed Apr 9, 2024
1 parent 40085b6 commit b82c31f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion frontend/src/modules/utils/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ interface ItemWithOrder {
order?: null | number;
}

export const uniqBy = <T extends Record<string, any>, K extends keyof T>(arr: T[], key: K): T[] =>
export const uniqBy = <T extends Record<K, string>, K extends keyof T>(arr: T[], key: K): T[] =>
Array.isArray(arr)
? arr.filter((item, index, self) => index === self.findIndex(y => item[key] === y[key]))
: [];
Expand Down

0 comments on commit b82c31f

Please sign in to comment.