Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.
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

@JamesHenry

Description

@JamesHenry

(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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions