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

Unused static method on class declared inside a function is not removed #2806

Open
WearyMonkey opened this issue Feb 3, 2018 · 0 comments
Open

Comments

@WearyMonkey
Copy link
Contributor

Input:

function zaa() {
  class Foo {
    static fee() { console.log('fee') }
    static baa() { console.log('baa') }
  }
  Foo.baa()
};
zaa();

Output:

(function() {
  function a() {
  }
  a.b = function() {
    console.log("fee");
  };
  a.a = function() {
    console.log("baa");
  };
  a.a();
})();

Expected the unused fee method to be removed.

Compare to global scope declaration, input:

class Foo {
  static fee() { console.log('fee') }
  static baa() { console.log('baa') }
}
Foo.baa();

output:

console.log("baa");

Object literal, input:

function zaa() {
  const Foo = {
  	fee() { console.log('fee') },
    baa() { console.log('baa') }
  }
  Foo.baa()
  
};
zaa();

output:

console.log("baa");

Prototype methods, input:

function zaa() {
  class Foo {
  	fee() { console.log('fee') }
    baa() { console.log('baa') }
  }
  new Foo().baa()
  
};
zaa();

output:

(function() {
  function a() {
  }
  a.prototype.a = function() {
    console.log("baa");
  };
  (new a).a();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant