This is a migrated thread and some comments may be shown as answers.

Angular 9, strict templates, incompatible types build errors

1 Answer 610 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
esp
Top achievements
Rank 1
Veteran
esp asked on 24 Feb 2020, 09:51 PM

After enabling the strictTemplates compiler option in Angular 9 I am seeing a number of build errors with the TreeView. The all amount to the same issue of incompatible types, for instance relating to the children property:

 

error TS2322: Type '(node: MyType) => Observable<MyType[]>' is not assignable to type '<T>(item: T) => Observable<any[]>'

 

Not sure what the correct resolution is here.

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 26 Feb 2020, 03:26 PM

Hi,

Thank you for the provided feedback.

It seems that the TypeScript does not recognize the types, set in our code. I consulted this issue with the assigned developer and I can assure you that we will investigate further modify the defined types in the implementation of the TreeView. 

Also, I have also updated your account Telerik points for bringing this issue to our attention.

Here is an example that reproduces the reported error:

https://stackblitz.com/edit/angular-yu1fov?file=app/app.component.ts

A workaround that I can provide is to set the fetchChildren argument type to any:

  public fetchChildren(node: any): Observable<any[]> {
    return of(node.items);
  }

Feel free to contact us back if any further questions come up and accept our apologies for the caused inconvenience until the issue is resolved.

Regards,
Martin
Progress Telerik

Get quickly onboarded and successful with your Telerik and Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Jordan
Top achievements
Rank 1
commented on 07 Jun 2021, 11:09 PM

hello, any resolution to this issue? I am getting the same error when I use strict mode in an angular project.
In the mean time, for a workaround: if I combine
"strictTemplates": true,
"strictInputTypes": false
the errors go away. Mine is appearing on the width size of the grid column
Martin
Telerik team
commented on 09 Jun 2021, 02:05 PM | edited

Hi Jordan,

The initial issue with the TreeView component seems to be resolved. Reusing the same template (as the one used here), but with the latest Kendo package versions (TreeView - v5.3.1), doesn't throw any type errors:

https://stackblitz.com/edit/angular-nb8tkq?file=app%2Fapp.component.ts

Regarding your scenario, I assume that the Grid component is used and the width property is bound like:

   <kendo-grid-column field="ProductID" title="ID" width="40" [filterable]="false">
    </kendo-grid-column>


Please could you try surrounding the width input with square brackets like:

   <kendo-grid-column field="ProductID" title="ID" [width]="40" [filterable]="false">
    </kendo-grid-column>

 

and check if the errors are gone. Also please refer to the following thread for related  type errors when using the State object:

https://www.telerik.com/forums/is-kendo-ui-compatible-with-angular-s-strict-mode

Regards,
Martin
Progress Telerik

 

Luis
Top achievements
Rank 1
commented on 05 Nov 2021, 02:50 PM

Hello,

 

I still have the error on the kendo grid.

 

Any suggestion to solve this using the strictTemplates?

 

Thanks

Martin
Telerik team
commented on 09 Nov 2021, 11:40 AM

Hi Luis,

Please check the following forum thread where similar questions are discussed:

https://www.telerik.com/forums/is-kendo-ui-compatible-with-angular-s-strict-mode

Regards

Tags
TreeView
Asked by
esp
Top achievements
Rank 1
Veteran
Answers by
Martin
Telerik team
Share this question
or