-
Notifications
You must be signed in to change notification settings - Fork 88
Description
Are you using the latest verion of NUglify, especially if used through BunderMinifier? Update before raising a bug as your issue is probably already fixed.
Using latest 1.21.17
Describe the bug
When uglifying javascript the static keyword on functions can be removed, causing code to not execute properly.
To Reproduce
The minimal repro I've created is to have this base TS code:
namespace Test { export class TestElement extends HTMLElement { public static readonly tagName = "test" as const; public static override [Symbol.hasInstance](instance: unknown) { return instance instanceof Element && instance.tagName.toLowerCase() === this.tagName.toLowerCase(); } } }
Compile it however you want, module/target version doesn't seem to change the end result of uglifying. But my repro is using tsconfig:
{ "compilerOptions": { "module": "ES2020", "target": "ES2019", } }
Then put that through Uglify.Js and receive the output with static keyword removed from the Symbol.hasInstance override. This dotnetfiddle has the example: https://dotnetfiddle.net/0ow2Qa
Minified output or stack trace
var Test;(function(n){class t extends HTMLElement{[Symbol.hasInstance](n){return n instanceof Element&&n.tagName.toLowerCase()===this.tagName.toLowerCase()}}t.tagName="test";n.TestElement=t})(Test||(Test={}))
Excepted output code
var Test;(function(n){class t extends HTMLElement{static [Symbol.hasInstance](n){return n instanceof Element&&n.tagName.toLowerCase()===this.tagName.toLowerCase()}}t.tagName="test";n.TestElement=t})(Test||(Test={}))