Skip to content

Unused identifier fixes #9431

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
wants to merge 18 commits into from
Closed

Unused identifier fixes #9431

wants to merge 18 commits into from

Conversation

mhegazy
Copy link
Contributor

@mhegazy mhegazy commented Jun 29, 2016

Fixes #9402 and #9403

We defer checking function expressions and class expressions, and if we want to get the references marked correctly we need to do the reference validation after that is done.

This change refactors the unused local and parameter checking to use a list of deferred nodes to check later.

there are also some bug fixes that i ran into, like not reporting catch variable as unused, reporting unused type aliases, optional parameters, etc..

@@ -4959,6 +4961,10 @@ namespace ts {
// type reference in checkTypeReferenceOrExpressionWithTypeArguments.
links.resolvedSymbol = symbol;
links.resolvedType = type;

if (noUnusedIdentifiers && symbol !== unknownSymbol && !isInAmbientContext(node)) {
symbol.hasReference = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isReferenced?

@vladima
Copy link
Contributor

vladima commented Jun 29, 2016

LGTM modulo comments

@DickvdBrink
Copy link
Contributor

The code below gives me an error with this branch

tmp/test.ts(5,13): error TS6133: 'initializeInternal' is declared but never used.

If I change it to this.initializeInternal it works. Should I create a new issue for this?

class test {

    private initializeInternal() {
    }

    public test() {
        var x = new test();
        x.initializeInternal();
    }
}

@mhegazy
Copy link
Contributor Author

mhegazy commented Jun 30, 2016

thanks @DickvdBrink pushed a fix out in 1fa69ca. can you give this a try?

@mhegazy mhegazy closed this Jun 30, 2016
@mhegazy
Copy link
Contributor Author

mhegazy commented Jun 30, 2016

closing and reposting as #9452 to see if travis will pick it up.

@mhegazy mhegazy closed this Jun 30, 2016
@mhegazy mhegazy deleted the unusedIdentifierFixes-2 branch June 30, 2016 20:43
@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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants