How to use registerForIntl() with Typescript

2 Answers 87 Views
Grid
Antonio
Top achievements
Rank 1
Iron
Antonio asked on 20 Aug 2021, 10:25 AM | edited on 20 Aug 2021, 10:35 AM

I have a react class component in which I need to use kendo Internationalization. Kendo internationalization is already setup and working with some functional components.

Unfortunately when I follow Kendo's docs examples for registerForIntl() I get the following typescript error:

Argument of type 'typeof DataGrid' is not assignable to parameter of type 'ComponentClass<{}, any>'.
  Types of parameters 'props' and 'props' are incompatible.
    Type '{}' is missing the following properties from type 'DataGridProps': data, total, columns

Any tips on how to get registerForIntl() working with class components with custom props interface?

2 Answers, 1 is accepted

Sort by
0
Accepted
Antonio
Top achievements
Rank 1
Iron
answered on 23 Aug 2021, 09:32 AM

I had to cast my Class component to React.ComponentClass type. However could not do a direct casting, had to cast to unkown type first!

 

class DataGrid extends React.Component<DataGridPropsDataGridState> {

}

// cast to unknown first
registerForIntl(DataGrid as unknown as React.ComponentClass);
1
Stefan
Telerik team
answered on 23 Aug 2021, 11:06 AM

Hello, Antonio,

I saw that you already fixed this by using casting.

We discussed this as we had another request for this before and we agreed that we can improve that and we have made a PR to update the type. The next version will allow using custom types.

Regards,
Stefan
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
Antonio
Top achievements
Rank 1
Iron
Answers by
Antonio
Top achievements
Rank 1
Iron
Stefan
Telerik team
Share this question
or