First post so I hope I don't unintentionally violate any forum rules.
I'm using Highcharts with Typescript and React and I have annotated the options object using the Options type.
In the tooltip.pointFormatter function, "this" is of type "Point". When I console.log "this", I can see "fromNode" and "toNode" properties that contain a lot of useful information – in particular, I want to use "name" – but when I try to access these properties, I get a typescript error.
Code: Select all
Property 'fromNode' does not exist on type 'Point'
Property 'toNode' does not exist on type 'Point'
I've created a minimal demo of this: https://codesandbox.io/s/sankey-tooltip ... /index.tsx
In this example, the chart renders just fine, but in my codebase the typescript errors would prevent my build from completing.
Note that I have commented out my current workaround which is to extend the point type and type-cast "this" using the extended type, but this workaround feels like a brittle solution and I would prefer to avoid it.
My question comes in several parts:
- Are these types missing due to the types being incomplete or have they been intentionally left out?
- If they have been intentionally left out, could you provide a little context as to why they have been? e.g. These properties are intended to be used internally only and accessing these properties in this way should be avoided.
- Is there another (better) way I can get the name of the from and to nodes of the current point from inside the point formatter?
Cheers,
Andy.