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

false positive: no-shadowed-variable #1099

Closed
unional opened this issue Apr 9, 2016 · 6 comments
Closed

false positive: no-shadowed-variable #1099

unional opened this issue Apr 9, 2016 · 6 comments

Comments

@unional
Copy link
Contributor

unional commented Apr 9, 2016

tslint: 3.7.1

export default function applyMixins(
    derivedCtor: new (...args: any[]) => any,
    baseCtors: Array<new (...args: any[]) => any>): void {
    // ...
    });
};

error: shadowed variable: 'args'

@adidahiya adidahiya changed the title false negative: shadowed-variable false positive: no-shadowed-variable Apr 9, 2016
@bencoveney
Copy link
Contributor

bencoveney commented Aug 2, 2016

Have another set of reproduction steps if it helps. Presumably the same issue:

class MyClass { };

declare type MyConstructor = new (myVariable: any) => MyClass;

function MyFunction(constructor: MyConstructor)
{
    const myVariable = 1;
    console.log(myVariable);
}

tslint version 3.13.0

@adidahiya
Copy link
Contributor

@bencoveney which identifier is reported as shadowed in that example?

@bencoveney
Copy link
Contributor

Sorry, the error message is:

Shadowed variable: 'myVariable'

@IllusionMH
Copy link
Contributor

@adidahiya, @jkillian looks like parameters from ConstrustorType and FunctionType nodes shouldn't be added to scope. What do you think on this kind of fix?

@adidahiya
Copy link
Contributor

@IllusionMH sounds reasonable. I assume that those syntax kinds are distinct from constructor/function declarations? i.e. this would still produce a lint failure:

function MyFunction(x: any) {
  let x: string;
      ^ Shadowed variable 'x'
}

@jkillian
Copy link
Contributor

Fixed by #1482

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants