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
If an explicit type parameter is present on
reduce, it's unsafe forprefer-object-from-entriesto fix the problem because this type parameter will carry over tomapwhich will likely be incompatible:Full reproduction: https://stackblitz.com/edit/vitejs-vite-axdfht2u