Skip to content
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

Un-used properties/methods #10497

Closed
TheColorRed opened this issue Aug 23, 2016 · 5 comments
Closed

Un-used properties/methods #10497

TheColorRed opened this issue Aug 23, 2016 · 5 comments
Labels
Duplicate An existing issue was already created

Comments

@TheColorRed
Copy link

TheColorRed commented Aug 23, 2016

TypeScript Version: 1.8.10

I think that it would be a nice feature to let the user know what properties/methods are defined but unused, this would be done doing so by underlining the method/property with a green underline.

This would more than likely only affect private properties and methods. Here is an example:

class MyClass {

    // Warning saying that "This item is never used"
    private myString1: string;

    // Warning saying that "This item has been assigned to but is never used"
    private myString2: string = 'abc123';

    // No Warning since this could be used anywhere (such as an external library)  
    public myString3: string = '123456';

    // Warning saying that "This item is never used"
    private myMethod1(): void { }

    // No Warning since this could be used anywhere (such as an external library)    
    public myMethod2(): void { }

}

class MyClass2 extends MyClass { }
@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript In Discussion Not yet reached consensus labels Aug 23, 2016
@RyanCavanaugh
Copy link
Member

Unused protected still makes sense because a derivative outside your compilation could be using them. But private members could be checked for unusedness.

@TheColorRed
Copy link
Author

Okay, I have remove the protected part from the post.

@RyanCavanaugh RyanCavanaugh added Duplicate An existing issue was already created and removed In Discussion Not yet reached consensus Suggestion An idea for TypeScript labels Aug 23, 2016
@RyanCavanaugh
Copy link
Member

Actually this was implemented with the --noUnusedLocals flag in 2.0 #9200

@TheColorRed
Copy link
Author

@RyanCavanaugh that is only in the compiler though, and not visually in the editor right?

@mhegazy
Copy link
Contributor

mhegazy commented Aug 23, 2016

@TheColorRed it should work in the editor as well if you have the option set in your tsconfig.json. you need to make sure your editor is running against TS 2.0 .

@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

3 participants