Skip to content

Unused Error is misleading with side-effecting static properties #17624

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
aozgaa opened this issue Aug 4, 2017 · 3 comments
Closed

Unused Error is misleading with side-effecting static properties #17624

aozgaa opened this issue Aug 4, 2017 · 3 comments
Labels
Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it

Comments

@aozgaa
Copy link
Contributor

aozgaa commented Aug 4, 2017

The following fragment, which uses the static initialization of s, marks D unused today:

function sideAffecting(): number {
    console.log("called");
    return 10;
}

function foo() {
    class D {
        static s: number = sideAffecting();
    }
}
foo();

Initially mentioned in #16078 but this is a separate issue.

@RyanCavanaugh
Copy link
Member

What's not unused about D ?

@ghost
Copy link

ghost commented Aug 8, 2017

In const x = sideAffecting();, x is unused. The statement containing x does something, but it could be simplified to just sideAffecting();. (And it might be simplified to nothing at all if the side-effect is necessary to compute x but not desired if we don't need x.)

@mhegazy
Copy link
Contributor

mhegazy commented Aug 22, 2017

this seems like such a contrived use case of classes, that it would not be too much to ask to either disable the warning or write an extra C;.

@mhegazy mhegazy added the Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it label Aug 22, 2017
@mhegazy mhegazy closed this as completed Aug 22, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it
Projects
None yet
Development

No branches or pull requests

3 participants