|
|
|
|
|
by LittleLily
76 days ago
|
|
I agree it's a bit annoying, but a better solution than using `as` is just telling reduce what its generic type should be: tasks.reduce<Record<string, (t: typeof tasks[number]) => boolean>>((acc, item) => ..., {}) Also imo it's cleaner to reduce to an object with something like this as the callback: (acc, item) => ({ ...acc, [item.label]: t => t.label === item.label }) |
|