Skip to content

Bug: [no-shadow] inconsistent reports on function parameter names inside ambient declarations clashing with real variable declarations #10539

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
andreww2012 opened this issue Dec 22, 2024 · 0 comments · Fixed by #10543
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@andreww2012
Copy link

andreww2012 commented Dec 22, 2024

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=5.6.3&fileType=.tsx&code=CYUwxgNghgTiAEkoGdnwMoHsC2IDC0qAjPAN4CwAUPIpgHbIAuMArmI5jABRj1OvtOABVhRsALnhQ6ATwCUAbio1kOEAFkQjABaZgXXDr0iYYydPlLq8Vbk1HgAdQCWOgKIAPAA4RnYVwBKWiwwdAAqMl4gBlq6wCZiAPrmsnKS-M50AOZWNAD0efAAUixMUvAAZiAA7vDYnAiMIEzIAHTtyjZq9nEAgmBgIF6MmVl4UBAQAEZQYADWPBPTs3OSMQ4JElKp8AC8AHzblp22IEIwmFEwjDJrsBfVAGIsdOzO9Jsp8nuHAG6YzmAVgAvlQKi83vRaAxmGwODBNlw5GR4KDKODXiMoYY4ojkaRUWCIVi6HVYsZRNhEkiUWiMZDSfdME9ie86HjaVQqAV4O1WhgxAhtFAvFE6KN4NVXNp4DoEGIps4QHRGJVWVDQEhTCTxFzKJroHA1Zi2V1cM8TfQuPSSZ8jml4P9AVYbabXR9KTSCcCrNzCnz4FMWKq6JhVVKdLLtPLsIrlarfrBnFAphAEAbRCT4FxEzA8mnGHleDD4CAPGIfM00nqM0bc2aQAA1JMptNrMBLGbzO0WZEHR0AoFEy2kjuTLtzDnehTwHm9CCqeCh0swC4wNDOCqO2D5rRFviq5xoUogYDwTJMEBQM-RuA18CGhAFhvNmDJ1MgAAyWnbnZWm2-Rgvj7P5BxddVRz-btKUAr1UV9fUH1gBBizKU5X3fNM8APX9x3-SlsJhYCfgHZ1hwZRAoMnAiDzgn09R5AA5TAVzXDctzlGxhWAZlTyXQVzzQAADXMhN1SgqFrFDCDQLBcAIFBkAAJjITpUNhQRuHUgR4U2JTgNyBsej0dZcUpfT7RBKh620uFhHMqx6xxClTGwJSEKk40KNOC0GWtCC9IdJ0h0oet3XZByGP9dp4E4eAhILMT7y1aTFIwNQFNQABmVTrFszSeAPHT7NcrKDJObpyX0Zz4kpMrLKoNFn3y3S6qsZ8as2LKPKQo1wobXySX8kcuqCsDrNgLzbTaqLeRiuKhPUpKJMQlLEBk9L5JkgAWXKaBazhCphYqEUpbbyusU5jOqqrNnOhrKDRdToX4OzTtc3bdmzEDaSsZ7OrOvZvpI6dksfKbTR8iDhoZO6xrI0LJvCu6rCAA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1uQAsBDACYcA7uiiJo0DtEjgwAXxDygA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

The minimal reproduction is as follows:

declare class SomeClass {
  someMethod(methodParam: any); // ❌ `'methodParam' is already declared in the upper scope`
}
function methodParam() { }

If, however, function methodParam is instead a var, let or const declaration, the ESLint error is not triggered.

Quite a few more examples of this strange behavior are in the playground link.

ESLint Config

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

tsconfig

{
  "compilerOptions": {
    "strictNullChecks": true
  }
}

Expected Result

The error should always be reported or not reported no matter with what type of declaration the name of the parameter inside an ambient declaration clashes.

I personally can't tell whether it's technically shadowing or not. Perhaps having an option to treat clashes between real and ambient declarations' names as shadowing issues could be the solution.

Actual Result

The current behavior seems inconsistent to me.

Additional Info

No response

@andreww2012 andreww2012 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 Dec 22, 2024
@bradzacher bradzacher 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 Dec 22, 2024
@github-actions github-actions bot added the locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. label Jan 8, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 8, 2025
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 locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
2 participants