Skip to content

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

Closed
@andsens

Description

@andsens

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions