I came across a piece of TypeScript code where the keyword "this" is used as a parameter of a function. I'm curious to know the significance of this usage and why it is implemented like this in the following context: "brushended(this: SVGGElement) {".
function brushended(this: SVGGElement) {
let e = <D3BrushEvent<any>>d3.event;
let s: BrushSelection = e.selection;
if (!s) {
if (!idleTimeout) {
self.ngZone.runOutsideAngular(() => {
idleTimeout = window.setTimeout(idled, idleDelay);
});
return idleTimeout;
}
x.domain(x0);
y.domain(y0);
} else {
x.domain([s[0][0], s[1][0]].map(x.invert, x));
y.domain([s[1][1], s[0][1]].map(y.invert, y));
d3Svg.select<SVGGElement>('.brush').call(brush.move, null);
}
zoom();
}