Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Class extension

$
0
0
Hi Isomorphic,

As you guys know, I am working on adding Typescript definitions for SmartClient. I am having a hard time understanding inheritance though.

I have to admit that I am a Java developper, Javascript is familiar but not in the intricacies of protypes etc.

Obviously, the way you do inheritance is to define a new class and add properties to it, then calling the create method.

If I want to subclass it in a more natural way, I need a way to connect my subclass (in the Typescript sense) to the superclass (defined with isc.DefineClass...). So right now I'm pretty lost. I guess there could be ways to connect prototypes together somehow, but I would need more help from you to have a plan on the proper method.

Typescript extension:
Code:

class A{
}

class B extends A {
    constructor() {
        super();
    }
}

generates the following javascript

Code:

var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var A = (function () {
    function A() {
    }
    return A;
})();

var B = (function (_super) {
    __extends(B, _super);
    function B() {
        _super.call(this);
    }
    return B;
})(A);

How could I make a subclass have its own set of functions while still retaining the super class properties?

With the stuff I am working on, the superclass will be more easily understood, but the subclass still needs to be connected for everything to work.

Thanks for your suggestions

Viewing all articles
Browse latest Browse all 4756

Trending Articles