-
Notifications
You must be signed in to change notification settings - Fork 12k
Description
Expected behavior
When using a let chartInstance: Chart<TType> where TType is a generic such that: TType extends ChartType, accessing chartInstance.config.options?.plugins should cause no problems.
Current behavior
When using a let chartInstance: Chart<TType> where TType is a generic such that: TType extends ChartType, it turns out that accessing chartInstance.config.options?.plugins causes the following error:
Property 'plugins' does not exist on type '_DeepPartialArray<unknown> | (CoreChartOptions<TType> & ElementChartOptions<TType> & PluginChartOptions<TType> & DatasetChartOptions<...> & ScaleChartOptions<...>) | (Function & ... 4 more ... & ScaleChartOptions<...>) | _DeepPartialObject<...>'.
Property 'plugins' does not exist on type '_DeepPartialArray<unknown>'.(2339)
Reproducible sample
Optional extra steps/info to reproduce
No response
Possible solution
Most likely, to the ChartOptions interface, some part of the code introduces a DeepPartial<unknown[]> or alike. This results in ChartOptions<ChartType> being a union containing _DeepPartialArray<unknown>, which in turn breaks everything.
The most primitive and functional solution is excluding it manually from the ChartOptions type by wrapping the DeepPartial<...> with Exclude<..., DeepPartial<unknown[]>>.
Context
No response
chart.js version
4.4.3
Browser name and version
No response
Link to your project
No response