Extensions

class Size {
    width: number
    height: number

    constructor(width: number, height: number) {
        this.width = width
        this.height = height
    }
}

interface Size {
    get area(): number
}

Object.defineProperty(Size.prototype"area", {
    getfunction area() {
        return this.width * this.height;
    }
})

let size = new Size(45)
let area = size.area
//area is 20

console.log(`area is ${area}`)