-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[@typescript-eslint/no-shadow] false positives with static methods #2592
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
Comments
Yeah this is a difficult one. To make this work "properly", we'd have to restructure the class analysis to handle this. It'd be super weird to setup. It's probably better to just handle this in the rule - check the shadow and ignore it if the method is |
It looks like the problem is Conditional types had the same problem. You had to visit some of the children under one scope, and the "else" child under the original scope. Maybe it would be easier to have the upper score be a parameter instead of something that is pushed and popped. |
The class creates its own scope to contain both the generic type parameter decls, and for the class name (also the class heritage is referenced from within this scope). If you reference the class name from inside of the class, it references a variable defined inside of the class scope, not the variable defined in the parent scope. If we were to use the parent scope of the class scope, that would break that relationship, as the static method would reference the class variable defined in the parent scope. The true fix for this would be to nest an "instance" scope within the class scope, and then define the class generics and instance members within that child scope, and then define static members in the class scope itself. However this would be a large deviation from the core |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as resolved.
This comment was marked as resolved.
…owing class generics Fixes #2592 Unfortunately I think this is impossible to solve from the scope analysis side.. So I opted instead to just ignore it from the lint rule.
False positive reported for static methods with a type parameter with the same name as the containing class' type parameter.
In a static method, the type parameters for the class are not in scope because there's no instance.
The text was updated successfully, but these errors were encountered: