8000 Bug: [no-shadow] Doesn't catch shadowing of global types in generics · Issue #5935 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

Bug: [no-shadow] Doesn't catch shadowing of global types in generics #5935

8000
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
CreativeTechGuy opened this issue Nov 7, 2022 · 1 comment · Fixed by #10593
Closed
4 tasks done

Bug: [no-shadow] Doesn't catch shadowing of global types in generics #5935

CreativeTechGuy opened this issue Nov 7, 2022 · 1 comment · Fixed by #10593
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

@CreativeTechGuy
Copy link
CreativeTechGuy commented Nov 7, 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=MYGwhgzhAECyCeBhcUA8AJAKrAMgURAFMBbQgOwBcA+aAbwFgAoJgXyaYvgAdDpEBXCBQD2xTN14BeaGX7EARoQBOAbnaNQkGAmRbMAd2GoBQ0eJ40GzRm2uce0LLgIlyFaNKFKAlmQDmKkA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1uQAsBDACYcA7uiiJo0DtEjgwAXxDygA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

See Playground link above

ESLint Config

See Playground link above

tsconfig

See Playground link above

Expected Result

I expected both the HTMLElement generic and the HTMLElement type declaration to both be an error as they both shadow the global type of the same name. The type declaration does show an error (actually a TypeScript compiler error) but there is no error for shadowing the type via a generic. I'd expect no-shadow to catch shadowing with generics.

Actual Result

Only types which are defined in the module scope are identified as shadowing when used in generic declarations.

Additional Info

No response

Versions

package version
@typescript-eslint/eslint-plugin 5.42.1
@typescript-eslint/parser 5.42.1
TypeScript 4.8.4
ESLint 8.15.0
@CreativeTechGuy CreativeTechGuy 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 Nov 7, 2022
@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 Nov 7, 2022
@bradzacher
Copy link
Member

For comparison - the following similar value-space code is correctly reported:

{
  const foo = 1;
}
function foo() {}

I believe the rule needs to be taught that the ordering doesn't matter for types.

@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 21, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 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
Development

Successfully merging a pull request may close this issue.

2 participants
0