chartjs / chartjs-plugin-annotation

Annotation plugin for Chart.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error TS2567 when using this plugin in version 2.1.2

yKicchan opened this issue · comments

When I install this plugin and import it I get an error:

Error: node_modules/chartjs-plugin-annotation/types/index.d.ts:6:13 - error TS2428: All declarations of 'PluginOptionsByType' must have identical type parameters.

6   interface PluginOptionsByType<TType extends ChartType> {
              ~~~~~~~~~~~~~~~~~~~

I am using chartjs 4.2.1.
When using version 2.0.1 of this plugin everything works. However I dont think thats a proper solution.

Same here with new version I get this error

As workaround, you could set skipLibCheck: true to your tsconfig.

Yes, I have already solved this problem using skipLibCheck, but I don't think that is a good way either!

@yKicchan let me ask you a couple of things:

  1. can you test your app with version 4.2.0 of CHART.JS? I have the feeling it sounds related to something in CHART.JS because I have seen other issues (the same here) on other plugins (datalabels, zoom).
  2. can you provide us a sample in order to reproduce the issue or provide the environment versions (frameworks you are using, versions)?

@LeeLenaleee @kurkle any thought? You know, my knowledge on TS is not so good...

@stockiNail I'm using chart.js 4.2.0 and the the latest version of this plugin and it is not working,
I have tried to install an older version of this package (even though that's not a good idea ) and it wont install because it says it is not compatible with the cahrt.js newer version

@stockiNail I'm using chart.js 4.2.0 and the the latest version of this plugin and it is not working,
I have tried to install an older version of this package (even though that's not a good idea ) and it wont install because it says it is not compatible with the cahrt.js newer version

Thank you @navelya . I did some tests on different TS versions, using chart.js 4.2.1 and the last version of plugin 2.1.2 but I wasn't able to reproduce the issue. Can you provide me more info about your environment in order to try to reproduce the issue?

@stockiNail I'm using chart.js 4.2.0 and the the latest version of this plugin and it is not working,
I have tried to install an older version of this package (even though that's not a good idea ) and it wont install because it says it is not compatible with the cahrt.js newer version

Thank you @navelya . I did some tests on different TS versions, using chart.js 4.2.1 and the last version of plugin 2.1.2 but I wasn't able to reproduce the issue. Can you provide me more info about your environment in order to try to reproduce the issue?

Im using angular in my project and also another chart.js plugin, if it working on chart.js 4.2.1 perhaps its chart.js problem even though a diffrent plugins are working, I can't use chartmjs 4.2.1 in my project because it is not up to me so the entire project is on 4.2.0.

@navelya I have created a sample app by Angular (15.2.0). I have added chartjs (4.2.1 and also with 4.2.0), plugin annotation (2.1.2) and datalabels (2.2.0) and it's working. The chart, annotations and labels are well rendered and no issue from TS (4.9.5). I'll take more time in the next days if I can reproduce the issue.

Hi @stockiNail . I am able to reproduce the exact same issue with Chart.js v4.2.1. Please help address this issue.

Hi @stockiNail . I am able to reproduce the exact same issue with Chart.js v4.2.1. Please help address this issue.

Can you provide the reproducible sample?

@navelya @tmarimut after another check, our guess is that you, which experiencing this issue, have multiple versions of Chart.js in node_modules, so could you should check your lock files?

@navelya @tmarimut after another check, our guess is that you, which experiencing this issue, have multiple versions of Chart.js in node_modules, so could you should check your lock files?

That's could be it, I will check it as fast as I can, thank u!

@stockiNail Attached you find a reproducible sample. In this case its a combination of chart.js@4.2.1, chartjs-plugin-annotation@2.2.1 and chartjs-plugin-zoom@2.0.1 causing this issue.

chartjs-plugins-test.zip

@KevinSafeguard thank youuuu! very helpful! I think it's Chart.js issue and I raised it in chartjs slack dev channel. I'm thinking that because if you change the sequence of the "import"s for zoom and annotation plugins in your code (chart.component.ts file) then the error is occurring for zoom plugin instead of the annotation one.

I saw the same bug today, but after re-install all packages, it worked.

Again the same problem this morning without reason. I did not understand how to fix it in #877
I have all these versions :
"chart.js": "^4.3.0",
"chartjs-adapter-moment": "^1.0.1",
"chartjs-plugin-annotation": "^2.2.1",
"chartjs-plugin-zoom": "^2.0.1",
Is the solution to downgrade ?

The fix has not been released yet. It will be with next version.