-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Typehinting ChartOptions seems broken for pie and doughnut #10896
Comments
I ran into a similar issue today when upgrading typescript from 4.8.2 to 4.9.3:
|
I'm also seeing this with chart.js 4.1.2, when upgrading typescript from 4.8.4 to 4.9.4. I see the same error starting from typescript 4.9.1-beta. I'm also using
..fails with:
There seems to be some interaction with the plugin. If I provide an empty list, or remove the
The chart itself renders fine if the TS error is suppressed with |
Still seeing it on 4.2.1, with ts 4.9.5. Errors about
|
For me, I just converted a file where I define Chart defaults and this was one that was erroring: ChartJs.defaults.animation.duration = 0;
is there any workaround to this? I'm new to TS and this was a bummer. |
This is also the case when you try to create a type guard export function isDoughnutConfiguration(config: ChartConfiguration): config is ChartConfiguration<'doughnut'> {
return (config as ChartConfiguration).type === 'doughnut';
} v3.8.2 |
Same here, I'm trying to use the cutout property from the doughnut chart: chartOptions: ChartOptions<'doughnut'> = {
cutout: 80
}; Output:
Version: 4.4.3 |
Also seeing above error on version 4.4.3, minimal example this this occurs on below: return new Chart(this.elementRef, {
type: 'pie',
data: {
labels: ["hi", "bye"],
datasets: [
{data: [1, 2]}
]
}
});
} |
Seeing same error as reported from user above for both 'pie' and 'doughnut'. Typescript version: Version 5.4.5
|
Also effects PolarAreaChart as well. |
* fix(#10896): correct typing for doughnut, pie, and polarArea charts * formatting
Expected behavior
I type hint
ChartOptions
orChartOptions<ChartType>
for a function and then pass a typehint ofChartOptions<'pie'>
orChartOptions<'doughnut'>
.Donut.vue:
The props typehinting in Base.vue:
Current behavior
I get the following error in vue-tsc:
Reproducible sample
Code provided in current behaviour
Optional extra steps/info to reproduce
No response
Possible solution
I couldn't find the reason why animation seems to not be compatible. However I did notice that in some areas animation is typehinted as:
animation: false | DoughnutAnimationOptions;
animation: false | PolarAreaAnimationOptions;
animation: AnimationSpec<TType>;
This might be the cause?animation: AnimationSpec<TType> | false;
Context
No response
chart.js version
v4.0.1
Browser name and version
No response
Link to your project
No response
The text was updated successfully, but these errors were encountered: