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

js file minify fail on Harmony(ES6+) option checked #645

Closed
jeffy-g opened this issue May 29, 2017 · 4 comments
Closed

js file minify fail on Harmony(ES6+) option checked #645

jeffy-g opened this issue May 29, 2017 · 4 comments

Comments

@jeffy-g
Copy link

jeffy-g commented May 29, 2017

Koala version

v2.2.0

Bug report or feature request?

Bug report

summary:

js file minify fail on Harmony(ES6+) option checked. (uglify-js@3.0.4

tsc: compile with target "es6"

ts file

declare interface IDummy {
    file(): void;
}

namespace lengthbug {
    export function createMessageFileX(): IDummy {
        return new MessageFileX();
    }
    /*export*/ class MessageFileX implements IDummy {
        private _messages: Array<JQuery> = [];
        public constructor() {}
        public file(): void {
            if (this._messages.length > 10) {
                console.log("out of bound!");
            }
        }
    }
}

js file

var lengthbug;
(function (lengthbug) {
    function createMessageFileX() {
        return new MessageFileX();
    }
    lengthbug.createMessageFileX = createMessageFileX;
    class MessageFileX {
        constructor() {
            this._messages = [];
        }
        file() {
            if (this._messages.length > 10) {
                              //^^^^^
                console.log("out of bound!");
            }
        }
    }
})(lengthbug || (lengthbug = {}));

error message appeared.
that message is:

"Cannot read property 'length' of undefined"
...

k193iy6

this is sample source.
well, these are uglify-js bug...

however, this is no error.

var lengthbug;
(function (lengthbug) {
    function createMessageFileX() {
        return new MessageFileX();
    }
    lengthbug.createMessageFileX = createMessageFileX;
    class MessageFileX {
        constructor() {
            this._messages = [];
        }
        file() {
            if (this._messages.length > 10) {
                console.log("out of bound!");
            }
        }
    }
    lengthbug.MessageFileX = MessageFileX; // <-- 
})(lengthbug || (lengthbug = {}));
@zaygraveyard
Copy link
Collaborator

This is a bug in UglifyJS, see mishoo/UglifyJS#2028
Also while test this I found another bug mishoo/UglifyJS#2027

@zaygraveyard
Copy link
Collaborator

I will improve the error message so it more descriptive.

@jeffy-g
Copy link
Author

jeffy-g commented May 31, 2017

i hope your improvement :-)

thanks 👍

@zaygraveyard
Copy link
Collaborator

Improve the error message so it more descriptive in v2.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants