Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

no-unused-vars - false positive for class props defined via public/private keywords in constructor #3

Closed
JamesHenry opened this issue Jan 14, 2016 · 2 comments
Labels

Comments

@JamesHenry
Copy link
Member

(Note: I am using ESLint via eslint-loader for webpack)
ESLint: 1.9.0
eslint-loader: 1.1.1
typescript-eslint-parser: 0.1.0-alpha-1

Take this valid ES2015 code:

class MyClass {
  constructor( foo ) {
    this.foo = foo
  }
  bar() {
    return this.foo
  }
}

In TypeScript, we can make use of the public or private keywords to skip having to manually assign the constructor param to the instance, so it becomes:

class MyClass {
  constructor( public foo ) {}
  bar() {
    return this.foo
  }
}

Currently the second version will erroneously produce a no-unused-vars error for foo because, as far as eslint is concerned, it is not used in the constructor

@nzakas
Copy link
Member

nzakas commented Jan 15, 2016

See comments on #4

@nzakas nzakas closed this as completed Jan 15, 2016
@fabienbranchel
Copy link

@nzakas : few months later, can it be consider now ?

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

No branches or pull requests

4 participants