Skip to content

Private methods accessed using bracket notation are reported as 'unused' #14186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kpreisser opened this issue Feb 20, 2017 · 1 comment
Closed
Labels
Duplicate An existing issue was already created

Comments

@kpreisser
Copy link
Contributor

TypeScript Version: Version 2.3.0-dev.20170220

Code

Compile with strictNullChecks, noImplicitAny, noUnusedLocals

class A {
    private abc(): number {
        return 1;
    }

    public callMethods() {
        let n = this["abc"]();
        console.log(n);
    }
}

Expected behavior:

No error.

Actual behavior:

C:\Users\User\Desktop\tstest>tsc --strictNullChecks --noImplicitAny -noUnusedLocals file1.ts
file1.ts(2,13): error TS6133: 'abc' is declared but never used.

When hovering over n, the IDE displays let n: number so the compiler should know that abc is actually used in this case.

Thanks!

@DanielRosenwasser
Copy link
Member

Thanks for the report, but looks like a duplicate of #14137.

@DanielRosenwasser DanielRosenwasser added the Duplicate An existing issue was already created label Feb 20, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants