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

TSLint will not report unused variable on constructor parameter with modifier #1410

Closed
litera opened this issue Jul 18, 2016 · 1 comment
Closed

Comments

@litera
Copy link

litera commented Jul 18, 2016

Bug Report

  • TSLint version: TSLint for Visual Studio Code 0.5.32
  • TypeScript version: 1.8.10
  • Running TSLint via: Visual Studio Code 1.3.1

TypeScript code being linted

class SomeClass {
    // TSLint will report this variable isn't used
    private unusedVar1: any;
    constructor(
        // TSLint doesn't suggest to remove "private" keyword because of unused variable
        private unusedVar2: any 
    ) {
        // doesn't use this.unusedVar2
    }
}

with tslint.json configuration:

(include if relevant)

Actual behavior

TSLint doesn't report unused variable if local type-level variable is declared using accessibility modifier in constructor parameters list.

Expected behavior

When we add private/public/protected to a constructor parameter we also create a type-level variable.

  1. If we used this specific parameter in constructor just like a normal function call parameter (without using this) but don't access it anywhere else using this, TSLint should report unused local variable.
  2. If we used this specific parameter only inside a constructor but access it as local variable (using this) but nowhere else TSLint should suggest to not declare it as local variable but rather use it as normal function parameter (in reality to remove access modifier private/public/protected).
  3. If we didn't use this parameter at all, it should simply report unused parameter (and arguably unused local variable too).
@andy-hanson
Copy link
Contributor

Should be fixed by #2235.

@ajafff ajafff closed this as completed Oct 31, 2017
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

4 participants