Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 12.1.2 | Typescript error while importing chartjs-plugin-trendline #63

Open
anubhav-aggarwal opened this issue Jan 28, 2022 · 7 comments

Comments

@anubhav-aggarwal
Copy link

anubhav-aggarwal commented Jan 28, 2022

I followed the instructions to install the plugin in my Angular 12.1.2 application using -
npm i chartjs-plugin-trendline

On importing chartTrendLine, using this command -
import {Chart, ChartConfiguration, ChartDataset, registerables} from 'chart.js';
import chartTrendline from "chartjs-plugin-trendline";

I get the following error -
"TS7016: Could not find a declaration file for module 'chartjs-plugin-trendline'. '/Users/anubhav.aggarwal/Documents/polaris-repo/polaris-web-app/node_modules/chartjs-plugin-trendline/src/chartjs-plugin-trendline.js' implicitly has an 'any' type.   Try npm i --save-dev @types/chartjs-plugin-trendline if it exists or add a new declaration (.d.ts) file containing declare module 'chartjs-plugin-trendline';"

Hence, I'm not able to register the plugin using following command -
Chart.register(chartTrendline);

Kindly help.

@Makanz
Copy link
Owner

Makanz commented Feb 7, 2022

I don't have any experience with Angular 12. I hope someone see this and can help.

@Makanz
Copy link
Owner

Makanz commented Feb 7, 2022

I have released a new version. Please try it and see if it solves your problem. @anubhav-aggarwal

@BowieAtSemso
Copy link

Hello, I've tried to install the package on a node.js environment and the same issue still seems to persist. I'm getting the same error where it seems to be missing a .d.ts file.

I simply ran npm i chartjs-plugin-trendline. That didn't work so I tried npm i chart.js chartjs-plugin-trendline which also didn't work. I followed the error and ran npm i --save dev @types/chartjs-plugin-trendline which, according to visual studio code, could solve the issue but it didn't work either.

I'm looking through your github repo and I can't find a .d.ts file anywhere I can manually add. Could you maybe look into adding a .d.ts file? It seems like that's the only issue but maybe you know more about this issue than I do and I'm simply doing something wrong so let me know, thanks in advance!

@Ferotiq
Copy link

Ferotiq commented Mar 19, 2022

I opened a pr for DefinitelyTyped to have types implemented for this plugin.

@Ferotiq
Copy link

Ferotiq commented Mar 21, 2022

It's now published and you can install @types/chartjs-plugin-trendline

@Makanz
Copy link
Owner

Makanz commented Mar 22, 2022

Thanks @Ferotiq

@tvld
Copy link

tvld commented Oct 31, 2022

Very nice... But I can not seem to get to use it. Is there a documentation paragraph? )) I ran npm install --save-dev @types/chartjs-plugin-trendline but that was not enough?

Edit: or you can restart vs-code and then it works ;-P )))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants