0

I'm upgrading Angular from 13 to 16, and after update I'm getting next error:

Error: some.component.ts:15:5 - error TS2322: Type '_DeepPartialObject<CoreChartOptions<"doughnut"> & ElementChartOptions<"doughnut"> & PluginChartOptions<"doughnut"> & DatasetChartOptions<"doughnut"> & ScaleChartOptions<...> & DoughnutControllerChartOptions> | undefined' is not assignable to type '_DeepPartialObject<CoreChartOptions & ElementChartOptions & PluginChartOptions<...> & DatasetChartOptions<...> & ScaleChartOptions<...>> | undefined'.

15 [options]="pieChartOptions">

Compiler highlights error at component template:

template: `
        <canvas *ngIf="(pieChartData$ | async) as data" baseChart
            [data]="data"
            [type]="pieChartType"
            [plugins]="pieChartPlugins"
            [options]="pieChartOptions">
        </canvas>
        <div *ngIf="!(pieChartData$ | async)" class="no-data-placeholder">
            {{ getNoDataPlacehoderText() }}
        </div>
    `,

Where piechart options and other chart data declared as:

export class RevenueDashboardCardPieChartComponent extends RevenueDashboardCardBaseComponent<ChartData<"doughnut">> {
        @ViewChild(BaseChartDirective) chart: BaseChartDirective | undefined;
   
     pieChartOptions: ChartConfiguration<"doughnut">["options"] = {
        some options data
        plugins: {
            some options for plugins
        }
    };

    pieChartType: ChartType = "doughnut";
    pieChartData$: Observable<ChartData<"doughnut"> | undefined>;
    pieChartPlugins = [ DataLabelsPlugin ];

}

Any ideas on what this error means an how to get it fixed? I had "similar" errors for FormControls, but it could be fixed by specifying generic type when creating control. Not sure how to fix it in pieChart case. Appreciate any help.

I had "similar" errors for FormControls, but it could be fixed by specifying generic type when creating control. Not sure how to fix it in pieChart case.

Radamant
  • 21
  • 3
  • Do you link to the correct (latest) chart.js typings (e.g., [4.4.0](https://github.com/chartjs/Chart.js/blob/v4.4.0/src/types/index.d.ts))? By the error message I'd guess the types it checks against are an older version where `CoreChartOptions` and `ElementChartOptions` where not generic. – kikon Aug 31 '23 at 00:48

0 Answers0