Import error: "Module 'chartjs-plugin-datalabels/types/index' has no default export."
See original GitHub issueTrying out Chart.js, and have been told I need to use the chartjs-plugin-datalabels to be able to write the percentage text on the piew pieces.
I installed and imported the chartjs-plugin-datalabels
as per the documentation into my Angular 7 project (actually Ionic 4, which uses Angular 7), but vscode reports the following error on the import…
Module '"../../../../node_modules/chartjs-plugin-datalabels/types"' has no exported member 'ChartDataLabels'.ts(2
I have the following versions
"chart.js": "^2.8.0", "chartjs-plugin-datalabels": "^0.6.0",
If I go to the node_modules\chartjs-plugin-datalabels\types\index.d.ts file, I also see a similar error here for the line
declare module 'chart.js
Invalid module name in augmentation. Module 'chart.js' resolves to an untyped module at 'd:/dev/ionic/chartjstest/node_modules/chart.js/dist/Chart.js', which cannot be augmented.ts
If I proceed, and try to run, I then get the compile error
[ng] ERROR in node_modules/chartjs-plugin-datalabels/types/index.d.ts(5,16): error TS2665: Invalid module name in augmentation. Module 'chart.js' resolves to an untyped module at 'D:/dev/ionic/chartjstest/node_modules/chart.js/dist/Chart.js', which cannot be augmented. [ng] src/app/home/pie-graph/pie-graph.component.ts(3,10): error TS2305: Module '"D:/dev/ionic/chartjstest/node_modules/chartjs-plugin-datalabels/types/index"' has no exported member 'ChartDataLabels'.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:27 (7 by maintainers)
Top GitHub Comments
@simonbrunel the correct way to import the library and get a reference to the output in Typescript is
import * as ChartDataLabels from 'chartjs-plugin-datalabels';
(based on how the library is currently being exported)You can fix this issue with installing the types for Chart.js via
npm install @types/chart.js