Closed
Description
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have read the FAQ and my problem is not listed.
Repro
{
"rules": {
"@typescript-eslint/<rule>": ["prefer-reduce-type-parameter"]
}
}
// first case
export function normalizeParams<P>(params: P): P {
return Object.entries(params).reduce((acc, [key, value]) => {
value = typeof value === 'string' ? value.trim() : value;
if (value) {
acc[key as keyof P] = value;
}
return acc;
}, {} as P);
}
// second case
export type Keys<T> = { [Key in keyof T]: Key };
export const toKeys = <T>(source: T): Keys<T> =>
Object.keys(source).reduce((acc, k) => {
const key = k as keyof T;
acc[key] = key;
return acc;
}, {} as Keys<T>);
Expected Result
Ignore such cases
Actual Result
Error reporting
Additional Info
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
4.24.0 |
@typescript-eslint/parser |
4.24.0 |
TypeScript |
4.2.4 |
ESLint |
7.27.9 |
node |
12.22.1 |