chartjs / chartjs-plugin-annotation

Annotation plugin for Chart.js
MIT License
603 stars 325 forks source link

Error TS2567 when using this plugin in version 2.1.2 #854

Closed yKicchan closed 1 year ago

yKicchan commented 1 year ago

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.

navelya commented 1 year ago

Same here with new version I get this error

stockiNail commented 1 year ago

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

yKicchan commented 1 year ago

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

stockiNail commented 1 year ago

@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...

navelya commented 1 year ago

@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 commented 1 year ago

@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?

navelya commented 1 year ago

@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.

stockiNail commented 1 year ago

@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.

tmarimut commented 1 year ago

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

stockiNail commented 1 year ago

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?

stockiNail commented 1 year ago

@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 commented 1 year ago

@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!

KevinSafeguard commented 1 year ago

@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

stockiNail commented 1 year ago

@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.

rfrancois commented 1 year ago

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

rfrancois commented 1 year ago

Again the same problem this morning without reason. I did not understand how to fix it in https://github.com/chartjs/chartjs-plugin-annotation/pull/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 ?

stockiNail commented 1 year ago

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