I'm converting a codebase from js to ts and stumbled upon a conundrum: extending external js object property getters and setters.
interface Player {
name: string;
position: { x: number; y: number };
_posHistory: [{ x: number; y: number }];
structures: Structures[];
}
Object.defineProperty(Player.prototype, "position", {
get() {
return this.pos; // i get "Unsafe member access .pos on an any value"
},
set(pos) {
this._posHistory.push(pos); //same here
this.pos = pos; //and here
},
configurable: false
});
How do I go about type hinting "this" keyword to TS in this situation so its not "any"?