If an explicit type parameter is present on reduce
, it's unsafe for prefer-object-from-entries
to fix the problem because this type parameter will carry over to map
which will likely be incompatible:
array.reduce<Record<string, Data & { b?: string }>>(
(res, entry) => ({ ...res, [entry.id]: entry.data }),
{}
);
// is transformed by the rule to ...
// but this type parameter v is wrong for `map`
Object.fromEntries(array.map<Record<string, Data & { b?: string }>>(
( entry) => [entry.id, entry.data]
));
Full reproduction: https://stackblitz.com/edit/vitejs-vite-axdfht2u
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too