0👍
The problem with module augmentation is always to find exactly what you want to augment. In this case you may think you want to augment the chart.js
module but if we look at the definitions we see export as namespace Chart;
This is an export for an UMD module and it is actually exporting a global class as a module (docs).
So the module is just referencing the global Chart
class, this is what we really want to augment.
import * as Chart from 'chart.js';
type Tooltip = {t: any}
declare global {
interface Chart {
pluginTooltips?: Tooltip[];
}
}
let c = new Chart(null!, null!);
c.pluginTooltips; // ok now
- Chartjs-Created an onclick function to remove data from a line chart in ChartsJs, but getting "Cannot read property 'data' of undefined" error
- Chartjs-Passing data in array that came from an array to chartjs with django
Source:stackexchange.com