benmerckx / genes

Generates split ES modules and Typescript definitions from Haxe modules.
44 stars 8 forks source link

Missing `;` in output #8

Closed kevinresol closed 4 years ago

kevinresol commented 4 years ago

Source: https://github.com/kevinresol/spectatory/blob/abf98bc6169d56ca56ad913b7635d75ca76195b1/src/spectatory/Location.hx#L11-L26

Generated js:

Location.href = (function($this) {var $r0
    var this1 = new SimpleState(window.location.href, null, null)
    var s = this1

            (function () {

                if ( typeof window.CustomEvent === "function" ) return;

                function CustomEvent ( event, params ) {
                    params = params || { bubbles: false, cancelable: false, detail: undefined };
                    var evt = document.createEvent( "CustomEvent" );
                    evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
                    return evt;
                }

                CustomEvent.prototype = window.Event.prototype;

                window.CustomEvent = CustomEvent;
            })();

Note that this1 is being called as a function in the js because of the missing ;

back2dos commented 4 years ago

Does anybody know how ASI is supposed to work? I think I'll never get it ...

kevinresol commented 4 years ago

seems like it inserts when there is newline + invalid token encountered. in this case the latter is not fulfilled

benmerckx commented 4 years ago

Semicolons are inserted to separate expressions in block body. I just forgot to do that when the block is generated as a value :)