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

Pure notation in static class property declaration is not respected if function references class itself #1444

Open
danieltroger opened this issue Sep 8, 2023 · 1 comment

Comments

@danieltroger
Copy link

danieltroger commented Sep 8, 2023

Bug report or Feature request?
Bug

Version (complete output of terser -V or specific git commit)

5.19.4

Complete CLI command or minify() options used

try.terser.org

terser input

class myClass extends EventTarget {
  static #happenedEvents = /*@__PURE__*/(() => {
    const set = new Set();
    window.addEventListener("event", e => myClass.#happenedEvents.add(e));
    return set;
  })();
  
  #classProperty = "Whole class doesn't get stuff removed now at all";
}

terser output or error

class e extends EventTarget{static#e=(()=>{const t=new Set;return window.addEventListener("event",(t=>e.#e.add(t))),t})();#t="Whole class doesn't get stuff removed now at all"}

Expected result

EventTarget

(Or ideally if something like #1443 is implemented, nothing)

@danieltroger danieltroger changed the title Pure notation in static class property is not respected if function references class itself Pure notation in static class property declaration is not respected if function references class itself Sep 8, 2023
@bgoscinski
Copy link

It would also be really cool if a class declaration could be annotated with /*@__PURE__*/ somehow:

input:

/*@__PURE__*/class o {
  static {
    o.prototype.foo = 'bar'
  }
}

actual output:

class o{static{o.prototype.foo="bar"}}

expected output:

// nothing

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

2 participants