Last active
August 29, 2015 14:06
-
-
Save mwisnicki/4b32f48c3c34a6152014 to your computer and use it in GitHub Desktop.
TypeScript property override proposal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 __findPropertyDescriptor = this.__findPropertyDescriptor || function(o, p) { | |
while (o !== null) { | |
var r = Object.getOwnPropertyDescriptor(o, p); | |
if (r) return r; | |
o = Object.getPrototypeOf(object); | |
} | |
return undefined; | |
}; | |
var Base = (function () { | |
function Base() { | |
} | |
Object.defineProperty(Base.prototype, "foo", { | |
get: function () { | |
return "Foo!"; | |
}, | |
enumerable: true, | |
configurable: true | |
}); | |
return Base; | |
})(); | |
var Derived = (function (_super) { | |
__extends(Derived, _super); | |
function Derived() { | |
_super.apply(this, arguments); | |
} | |
var _super_get_foo = __findPropertyDescriptor(_super.prototype, "foo").get; | |
Object.defineProperty(Derived.prototype, "foo", { | |
get: function () { | |
return "Derived " + _super_get_foo.call(this); | |
}, | |
enumerable: true, | |
configurable: true | |
}); | |
return Derived; | |
})(Base); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Base { | |
get foo() { return "Foo!"; } | |
} | |
class Derived extends Base { | |
get foo() { | |
return "Derived " + super.foo; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment