Skip to content

Properties retrieved via destructuring do not mark that property as being used #11324

Closed
@tomdale

Description

@tomdale

TypeScript Version: 2.1.0-dev.20161003

Code

class Animal {
  constructor(private species: string) {
  }

  printSpecies() {
    let { species } = this;
    console.log(species);
  }
}

Expected behavior:
If I have the noUnusedLocals option enabled, the code should compile without warnings because the species property is being used.

Actual behavior:
If I have the noUnusedLocals option enabled, I receive:

src/index.ts(2,23): error TS6138: Property 'species' is declared but never used.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions