While I have a good understanding of how module augmentation works, I am struggling to obtain the object reference in the new method's implementation.
To provide an example, I aim to enhance the es2015 Map interface.
In my code, I include:
declare global{
interface Map<K, V> {
newMethod(g: K): V;
}
}
This setup appears to be functioning correctly as I can observe the new method in my other code.
However, when attempting to implement this new method, I am uncertain of how to access a reference on the Map instance to make further calls to other methods like `get` or `keys`.
I experimented with the following approach:
Map.prototype.newMethod = k => {
...
let leys = this.keys();
...
}
Unfortunately, this solution does not work as expected.
Could you please advise me on how to tackle this issue?