Skip to content

Bug: [typescript-eslint/no-shadow] Rest (...args) parameter name in generic declaration shadows actual parameter name #5853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 tasks done
andsens opened this issue Oct 20, 2022 · 0 comments · Fixed by #5902
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@andsens
Copy link

andsens commented Oct 20, 2022

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

https://typescript-eslint.io/play/#ts=4.8.4&sourceType=module&code=PTAEDEEMEsBsGdQHdoBcAWoBEBySAnAc3h1GkUlnwFNIATAT1DuoGNYDq6yA7UDaqACuABxHV8oeKwD240DL6xoPQQCZQs2EIC2fAGwBWAHRYAUADMhPVqmiL+1eKihwAjAB5woagA9U1Dx0iAAUxuEExABcoJA8DADaALoAlKAAvAB8sfGZIRY8MeAANKDhxpHwMXGJqaAA3magoDSoQvh8CQWllUkA3GYAvmZmIBAwCMhomHhEJGQUVLSMzGwcNNwq-OiCouKS0nKCDsqqoADsmjLaeqD6asaW1rb2fAHOrrBqXj7+gcGgMIRObVeLJNJZHIMPIFIo9EFQ8ENJotahtDqgLo8eHEfpDEZjAAiMicoB4MlQoAsEyeNjsDneqAA6jJ8ABreA-PwBIKhSqghgQ7I1GGFCClcr8xF1RrNVrtTrdWJzPHDIA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUBILkB2A9gLTIAWAhgCYEDu6UBAZo5ADQg6QACALgJ4AHFAGNoASwE8iKeGLw8A9IRIVqdDJETRoBaJHBgAviENA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYwYAviDUA

Repro Code

// Fails with "'args' is already declared in the upper scope on line 2 column 65."
function testFail1<F extends (...args: any[]) => any>(fn: F, ...args: any[]) {
	return [fn, args];
}

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "no-shadow": "off",
    "@typescript-eslint/no-shadow": "error"
  },
};

tsconfig

{
  "compilerOptions": {  }
}

Expected Result

I expect no errors.

Actual Result

I get the error 'args' is already declared in the upper scope on line 2 column 65.

Additional Info

The argument name in the generic has no effect on the rest of the code. Granted, it's a bit confusing to read, because the two args are completely unrelated, but there's no shadowing going on here.

Versions

package version
@typescript-eslint/eslint-plugin 5.40.1
@typescript-eslint/parser 5.40.1
TypeScript 4.7.4
ESLint 8.25.0
node 16.18.0
@andsens andsens added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Oct 20, 2022
@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for team members to take a look labels Oct 20, 2022
JoshuaKGoldberg added a commit to yeonjuan/typescript-eslint that referenced this issue Nov 13, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
2 participants