typescript error when registering plugin
nbamfordcirium opened this issue · comments
Nathan Bamford commented
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",
Cash commented
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.
Simon Brunel commented
@MasterCash is right, it should be Chart.register(ChartDataLabels);
References: