Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play/#ts=6.0.3&fileType=.tsx&code=GYVwdgxgLglg9mABAZSgJxmA5gCgB4BciAzuplgJSIDeAUIomgKZQhpJ4DctAvrbaEiwEiYHDg5iRUhmxU6DZq3Yoy2SRW48gA&eslintrc=N4KABGBEAOCGBOBnApvSAuKABALgT2mUQGN4BLaHAWiIBsyA7HAejiVUgBpwo2V4A8pTIB7BogxhQECDHgiAVsmI5JkAHTMcJMQDMyAc3ULEYyDwC%2B3WfACutIpOkzIuAkVIVqdRiwYiqWwYGZSJEBDwqfEIqYjEAN1REUQY1VHk0SxALIA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eFYDAruuGAL4g9A&tokens=false
Repro Code
function String(x: string) {
return x;
}
function foo(s: string) {
return String(s);
}
ESLint Config
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
},
rules: {
"@typescript-eslint/no-unnecessary-type-conversion": "error",
},
};
tsconfig
Expected Result
no error
Actual Result
Passing a string to String() does not change the type or value of the string
and the "Remove the type conversion." suggestion rewrites String(s) to s, which changes what the code does
Additional Info
No response
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play/#ts=6.0.3&fileType=.tsx&code=GYVwdgxgLglg9mABAZSgJxmA5gCgB4BciAzuplgJSIDeAUIomgKZQhpJ4DctAvrbaEiwEiYHDg5iRUhmxU6DZq3Yoy2SRW48gA&eslintrc=N4KABGBEAOCGBOBnApvSAuKABALgT2mUQGN4BLaHAWiIBsyA7HAejiVUgBpwo2V4A8pTIB7BogxhQECDHgiAVsmI5JkAHTMcJMQDMyAc3ULEYyDwC%2B3WfACutIpOkzIuAkVIVqdRiwYiqWwYGZSJEBDwqfEIqYjEAN1REUQY1VHk0SxALIA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eFYDAruuGAL4g9A&tokens=false
Repro Code
ESLint Config
tsconfig
{ "compilerOptions": { "strict": true } }Expected Result
no error
Actual Result
and the "Remove the type conversion." suggestion rewrites
String(s)tos, which changes what the code doesAdditional Info
No response