I looked deeper into this and played with typescript Playground. I declared two classes, one with a getter, and the second with the get method, as described in your questions.
Let's see how it looks:
In the first example, we declared a method for obtaining the property value as follows:
class Greeter { greeting: string; constructor(message: string) { this.greeting = message; } getGreeting() { return this.greeting; } }
Which after translating to javascript is as follows:
var Greeter = (function () { function Greeter(message) { this.greeting = message; } Greeter.prototype.getGreeting = function () { return this.greeting; }; return Greeter; }());
And regarding the second example, where we declared a getter as follows:
class GetterGreeter { _greeting: string; constructor(message: string) { this._greeting = message; } get greeting() { return this._greeting; } }
Which after the translation is as follows:
var GetterGreeter = (function () { function GetterGreeter(message) { this._greeting = message; } Object.defineProperty(GetterGreeter.prototype, "greeting", { get: function () { return this._greeting; }, enumerable: true, configurable: true }); return GetterGreeter; }());
(You can play with javascript declaration and translation here )
As you can see using the get method (as in the first example), the method is declared in the prototype, and in the second example using the getter typescript template, the defineProperty api property is used.
In both cases, we invoke the method, and angular also invokes the method during change detection to identify changes and re-render.
As I see it, this is only syntactic sugar for the same approach, and I do not see any performance advantages for one of the methods.