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", {
get: function area() {
return this.width * this.height;
}
})
let size = new Size(4, 5)
let area = size.area
//area is 20
console.log(`area is ${area}`)