Data binding to observable throws error with strict type checking

1 Answer 124 Views
Charts
Megan
Top achievements
Rank 1
Iron
Iron
Megan asked on 21 Sep 2022, 07:11 PM
I'm trying to set up a chart whose data is bound to an observable. Even using the exact example on observables provided on the data binding page, it fails to compile with the error "Type 'number[] | null' is not assignable to type 'any[]'." How can I resolve this?

1 Answer, 1 is accepted

Sort by
0
Accepted
Megan
Top achievements
Rank 1
Iron
Iron
answered on 22 Sep 2022, 01:27 PM

I found the answer! Someone had the same problem in an entirely different Kendo widget.

The async pipe can return null, which was causing the problem. To fix it, change [data]="series | async" to [data]="(series | async)!", which assures the compiler that it will never be null.

Original post for reference: https://github.com/telerik/kendo-angular/issues/3210

Tags
Charts
Asked by
Megan
Top achievements
Rank 1
Iron
Iron
Answers by
Megan
Top achievements
Rank 1
Iron
Iron
Share this question
or