At the moment, my example is from the Highcharts library, but I'm asking the general question because I'd like to know how to solve this for any library.
My code snippet is as follows:
tooltip: {
formatter: function () {
return this.series.name + "," + this.point.y;
}
},
I'd like to work out the proper type for 'this'.
I've started by looking at the definition file:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/highcharts/index.d.ts
The relevant code seems to be as follows:
interface TooltipOptions extends SeriesTooltipOptions {
...
formatter?(): boolean | string;
...
}
Here, I get a little stuck. I've tried modifying the code to:
tooltip: {
formatter: function (this: Highcharts.TooltipOptions) {
return this.series.name + "," + this.point.y;
}
},
but that doesn't work.
What am I doing wrong and how do I work out the correct type?