chartjs/chartjs-plugin-datalabels

typescript error when registering plugin

nbamfordcirium opened this issue · 2 comments

The following code:

import {
  Chart,
} from 'chart.js';
import ChartDataLabels from 'chartjs-plugin-datalabels';
Chart.register([ChartDataLabels]);

produces the Typescript error Property 'id' is missing in type 'typeof import("/Users/bamfordn/airframe-components/node_modules/chartjs-plugin-datalabels/types/index")' but required in type 'ChartComponent'.

I have the following versions in package.json:

 "chart.js": "^4.2.1",
 "chartjs-plugin-datalabels": "^2.2.0",

shouldn't it just be:

import { Chart } from "chart.js";
import ChartDataLabels from "chartjs-plugin-datalabels";

Chart.register(ChartDataLabels);

This is what I am doing in my codebase and it seems to be working.