Skip to content

Instantly share code, notes, and snippets.

@gintsgints
Created August 23, 2015 16:43
Show Gist options
  • Save gintsgints/704ba90cdbdd5a92ac4e to your computer and use it in GitHub Desktop.
Save gintsgints/704ba90cdbdd5a92ac4e to your computer and use it in GitHub Desktop.
This is how Typescript generate supper call
var __extends = (this && 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 Person = (function () {
function Person(name, age) {
this.name = name;
this.age = age;
}
Person.prototype.getDescription = function () {
return "Returns person description";
};
return Person;
})();
var Man = (function (_super) {
__extends(Man, _super);
function Man(name, age) {
_super.call(this, name, age);
}
Man.prototype.getDescription = function () {
var desc;
desc = _super.prototype.getDescription.call(this);
return desc + this.name + " is " + this.age + " years old";
};
return Man;
})(Person);
var lee = new Man("Lee", 39);
console.log(lee.getDescription());
@gintsgints
Copy link
Author

Typescrpit compiled from:

class Person {
  constructor(public name:string, public age:number) {

  }

  getDescription():string {
    return "Returns person description";
  }
}

class Man extends Person {
  constructor(name: string, age: number) {
    super(name, age);
  }

  getDescription():string {
    var desc:string;
    desc = super.getDescription();
    return desc + this.name + " is " + this.age + " years old";
  }
}

var lee:Man = new Man("Lee", 39);

console.log(lee.getDescription());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment