This project is read-only.

context bounds property

Topics: Language Specification
Oct 30, 2012 at 3:32 PM
Edited Oct 30, 2012 at 3:33 PM

Having to use "this" all the time make a the syntax a little "verbose" i don't think it should be very hard to bind property to the right context at compile time : 

class Test {
   public property:string;
   public method():void {
       property = "Hello";


would be translated to : 

var Test = (function () {
    function Test() { }
    Test.prototype.method = function () { = "Hello";
    return Test;

Oct 30, 2012 at 9:05 PM

The short answer is that the class syntax comes from the ES6 proposed class syntax, which we're trying to match.  The longer answer is that there are subtle issues with not requiring it.  Specifically, if a parent class introduces, for example, a 'window' field, then it becomes difficult to reach out to the global one from a child class.