Closed as not planned
Closed as not planned
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Playground Link
Repro Code
[].reduce(x=>x, { __proto__: null } as unknown as Record<string, string>);
ESLint Config
module.exports = {
parser: "@typescript-eslint/parser",
rules: {
"@typescript-eslint/prefer-reduce-type-parameter": ["error"],
},
};
tsconfig
Expected Result
Quick Fix would transform the code to:
[].reduce<Record<string, string>>(x=>x, Object.create(null));
Actual Result
After applying Quick Fix:
[].reduce<Record<string, string>>(x=>x, { __proto__: null } as unknown);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Argument of type 'unknown' is not assignable to parameter of type 'Record<string, string>'. ts(2345)"
Then after second Quick Fix:
[].reduce<Record<string, string>>(x=>x, { __proto__: null });
~~~~~~~~~
"Type 'null' is not assignable to type 'string'. ts(2322)"
Additional Info
Object.create(null)
does not have the TypeScript problems that { __proto__: null }
does, and the latter should be transformed into the former before the pair of Quick Fixes are applied. All three transformations are required for eslint --fix
to not break anything.