Get/Set

For this TypeScript;

class foo {
    private _bar:Boolean = false;
    get bar():Boolean {
        return this._bar;
    }
    set bar(theBar:Boolean) {
        this._bar = theBar;
    }
}

It produces;

var foo = (function () {
    function foo() {
        this._bar = false;
    }
    Object.defineProperty(foo.prototype, "bar", {
        get: function () {
            return this._bar;
        },
        set: function (theBar) {
            this._bar = theBar;
        },
        enumerable: true,
        configurable: true
    });
    return foo;
})();

Is that how you are doing it, I havn't looked close yet.

Mike





On Wed, May 27, 2015 at 6:17 PM, Alex Harui <aha...@adobe.com> wrote:

>
>
> On 5/27/15, 1:54 PM, "Michael Schmalle" <teotigraphix...@gmail.com> wrote:
>
> >Ok,
> >
> >I am a doer... :) Since this is all POC right now and I am up to learn
> >some
> >JS, I will use this as a format. I have done this JSEmitter 2 times now so
> >the 3rd isn't going to be that hard, maybe the charm for me to.
> >
> >Note, most of the expressions and statements are already done. As noted,
> >inheritance, scope and set/get always are the pains but if I have a target
> >output protocol like TypeScript's output, why not emulate it.
> >
> >Alex, I know what you are thinking... Don't. :) My gut feeling is, if I
> >start from the ground up and have NO dependencies on anything, I will do
> >this twice as fast. I am very good at refactoring so once I have tests
> >working on the generated .js, we can see what could be abstracted to and
> >from this emitter and FlexJS.
> >
> >I really think for my own sanity, I need to start in isolation and not get
> >in FlexJS's way either, that is another pro for me, no commit conflicts,
> >nothing of that nature.
> >
> >Thoughts Josh, Alex?
>
> OK, have fun.  There isn’t too much emitter development going on right now
> so you could work in a branch if you want.
>
> BTW, I didn’t see how TS handles properties, but FlexJS is no longer using
> get_/set_ and now using Object.defineProperties.
>
> -Alex
>
>

Reply via email to