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

[Bug]: Type error for Line options with chartjs-zoom-plugin #1088

Open
1 task
wcheek opened this issue Apr 8, 2024 · 0 comments
Open
1 task

[Bug]: Type error for Line options with chartjs-zoom-plugin #1088

wcheek opened this issue Apr 8, 2024 · 0 comments

Comments

@wcheek
Copy link

wcheek commented Apr 8, 2024

Would you like to work on a fix?

  • Check this if you would like to implement a PR, we are more than happy to help you go through the process.

Current and expected behavior

The Line object should accept options with types needed to use chartjs-zoom-plugin.

When trying to build the project, I get the following error:

vite v5.1.0 building for production...
src/components/myFile.vue:23:7 - error TS2322: Type '{ responsive: boolean; maintainAspectRatio: boolean; plugins: { colors: { forceOverride: boolean; }; zoom: { pan: { enabled: boolean; mode: string; modifierKey: string; }; zoom: { mode: string; wheel: { enabled: boolean; }; pinch: { ...; }; drag: { ...; }; }; }; }; }' is not assignable to type '_DeepPartialObject<CoreChartOptions<"line"> & ElementChartOptions<"line"> & PluginChartOptions<"line"> & DatasetChartOptions<"line"> & ScaleChartOptions<...> & LineControllerChartOptions>'.

23       :options="options"
         ~~~~~~~~

  node_modules/vue-chartjs/dist/types.d.ts:18:5
    18     options?: ChartOptions<TType>;
           ~~~~~~~
    The expected type comes from property 'options' which is declared here on type 'Partial<{}> & Omit<{ readonly data: ChartData<"line", (number | Point | null)[], unknown>; readonly options?: _DeepPartialObject<CoreChartOptions<"line"> & ElementChartOptions<"line"> & PluginChartOptions<...> & DatasetChartOptions<...> & ScaleChartOptions<...> & LineControllerChartOptions> | undefined; readonly plu...'


Found 1 error.

ERROR: "type-check" exited with 2.

I've tried making options a reactive object. The only way I can get vite to not complain is by specifying const options: any = {...} but of course this is not ideal. Maybe this is a problem with the chartjs-zoom-plugin.

Reproduction

https://stackblitz.com/edit/github-am2v7z?file=src%2FchartConfig.ts

chart.js version

^4.4.2

vue-chartjs version

5.3.0

Possible solution

You can get around the bug by declaring the type of options as any but this is not a fix.

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

No branches or pull requests

1 participant