So I learned how to make extension in typescript:
interface Array<T> {
lastIndex(): number
}
Array.prototype.lastIndex = function (): number { return this.length - 1 }
But How to make a getter from it ? eg:
interface Array<T> {
get lastIndex(): number
}
Array.prototype.lastIndex = function (): number { return this.length - 1 }
So that I can just call is as getter in code someArray.lastIndex ?
I found this answer but code wont compile for generic types, also it's quite ugly to write this way but well maybe i ask for too much in typescript : How to extend a typescript class with a get property?