Is it possible to have functions in a base class, but lambda functions in a subclass?

I use a third-party api that has d.ts definitions, where the class has functions declared like this:

export class Bar {
    foo(): void;
}

now when i create an implementation of a subclass i want to use lambda function syntax

    export class Test1 extends Bar {
         public foo = (): void => {
              //DO Stuff
         }
    }

This does not compile because

"The class 'Test1' defines the property of the instance member 'foo', but the extended class 'Bar' defines it as a function of the instance member.

Do I need to change the definition of the Bar class to work with lambda functions? I would prefer that if there is another solution, I would appreciate help!

Update

, -. extends implements, lamdba Test1. . Bar , , - ?

+4
1

implements, , , , , , Test1.

implements , .

JavaScript:

var Foo = (function () {
    function Foo() {
        this.foo = function () {
        };
    }
    return Foo;
})();

extends, , Test1 .

extends , , .

JavaScript ( ):

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 Foo = (function (_super) {
    __extends(Foo, _super);
    function Foo() {
        _super.apply(this, arguments);
    }
    Foo.prototype.foo = function () {
    };
    return Foo;
})(Bar);
+2

All Articles