I was reading about how classes work and came across this:
This es6 syntax
class Point {
x: number;
y: number;
constructor(x: number, y: number) {
this.x = x;
this.y = y;
}
add(point: Point) {
return new Point(this.x + point.x, this.y + point.y);
}
}
gives an es5 emit as:
"use strict";
var Point =
/*#__PURE__*/
function () {
function Point(x, y) {
this.x = x;
this.y = y;
}
var _proto = Point.prototype;
_proto.add = function add(point) {
return new Point(this.x + point.x, this.y + point.y);
};
return Point;
}();
I'm not able to understand why the need for the trailing parentheses.