Chore: improve typing

This commit is contained in:
Pieter Vander Vennet 2025-04-09 17:10:33 +02:00
parent d01f830632
commit 01f1fbf89a
5 changed files with 38 additions and 14 deletions

View file

@ -332,9 +332,12 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
* @param toKey
* @constructor
*/
public static DedupOnId<T>(arr: T[], toKey: (t: T) => string): T[] {
public static DedupOnId<T = { id: string }>(arr: T[], toKey?: (t: T) => string): T[] {
const uniq: T[] = []
const seen = new Set<string>()
if (toKey === undefined) {
toKey = (item) => item["id"]
}
for (const img of arr) {
if (!img) {
continue