termi / es6-transpiler

Tomorrow's JavaScript syntax today
Other
216 stars 18 forks source link

Support for "super" keyword #35

Closed kobezzza closed 10 years ago

kobezzza commented 10 years ago
class Foo {
    constructor() {

    }
}

class Base extends Foo {
    constructor() {
        super.constructor();
    }
}

=>

var Foo = (function () {
    function Foo() {

    };
    return Foo;
})();

var Base = (function (super$0) {
    var MIXIN$0 = function (t, s) {
        for (var p in s) {
            if (s.hasOwnProperty(p)) {
                Object.defineProperty(t, p, Object.getOwnPropertyDescriptor(s, p));
            }
        }
        return t
    };
    MIXIN$0(Base, super$0);

    function Base() {
        super.constructor(); // bug
    }
    Base.prototype = Object.create(super$0.prototype, {
        "constructor": {
            "value": Base,
            "configurable": true,
            "writable": true
        }
    });;
    return Base;
})(Foo);
kasperisager commented 10 years ago

:+1:

cmmartin commented 10 years ago