Skip to content

noUnusedLocals flags decorated classes #13853

@roblourens

Description

@roblourens

TypeScript Version: 2.1.5 and latest 2.2.0

Code

@f
class A {
    private b;

    c() {

    }
}

export function f(ctor) {
    new ctor().c();
}

with tsconfig.json:

{
    "compilerOptions": {
        "noUnusedLocals": true,
        "target": "es6",
        "module": "commonjs",
        "experimentalDecorators": true
    }
}

Expected behavior:
A.b should be flagged as unused, but A should not be flagged as unused, because the decorator could be doing something useful with the class. This is a common pattern in our codebase.

Actual behavior:
A is flagged as unused

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions