Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

no-shadowed-variablee should not warn on static methods #3019

Closed
NN--- opened this issue Jul 9, 2017 · 2 comments · Fixed by #3030
Closed

no-shadowed-variablee should not warn on static methods #3019

NN--- opened this issue Jul 9, 2017 · 2 comments · Fixed by #3030

Comments

@NN---
Copy link
Contributor

NN--- commented Jul 9, 2017

Bug Report

  • TSLint version: 5.5.0
  • TypeScript version: 2.4.1
  • Running TSLint via: gulp

TypeScript code being linted

class A<T> {
 static f<T>(x: T): void {} // error
}

with tslint.json configuration:

{
  "rules": {"no-shadowed-variable": true }
}

Actual behavior

Complains on shadowed name 'T'

Expected behavior

No error since there is no shadowing.

@ajafff
Copy link
Contributor

ajafff commented Jul 9, 2017

You're right, technically there's no shadowing.
One could argue that it would be easier to understand if you don't use the same name for both type parameters.

I don't have a strong opinion on that. It would be some effort to implement it, but it's doable.

@benny-medflyt
Copy link

I'm being hit by this as well.
I think it's actually better for readability for both type parameters to have the same name if they are both referring to the "same thing"

Would be great if this was fixed 👍

adidahiya pushed a commit that referenced this issue Aug 2, 2017
[new-rule-option] `no-shadowed-variable` let's you optionally ignore certain kinds of declarations
[bugfix] `no-shadowed-variable` fixed false positive with parameter inside function decorator
Fixes: #3000
[bugfix] `no-shadowed-variable` don't warn for shadowed type parameter on static class members
Fixes: #3019
@adidahiya adidahiya added this to the TSLint v5.6 milestone Aug 2, 2017
HyphnKnight pushed a commit to HyphnKnight/tslint that referenced this issue Apr 9, 2018
[new-rule-option] `no-shadowed-variable` let's you optionally ignore certain kinds of declarations
[bugfix] `no-shadowed-variable` fixed false positive with parameter inside function decorator
Fixes: palantir#3000
[bugfix] `no-shadowed-variable` don't warn for shadowed type parameter on static class members
Fixes: palantir#3019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants