Check out example codes for "typescript extension getter". It will help you in understanding the concepts better.

Code Example 1

interface A {
    testGet: SomeType|null;
}

Object.defineProperty(A.prototype, "testGet", {
    get (this: A) {
        if(this.something) { 
          return this.something;
        }
        return null;
    },
    enumerable: false,
    configurable: true
});

Learn ReactJs, React Native from akashmittal.com