error TS2339: Property 'field' does not exist on type 'FilterDescriptor | CompositeFilterDescriptor'.

1 Answer 256 Views
Grid
Masip
Top achievements
Rank 1
Iron
Masip asked on 31 Jan 2022, 04:26 PM

https://stackblitz.com/edit/angular-xrfu5g-6fw38x

Error: src/app/app.component.ts:91:83 - error TS2339: Property 'field' does not exist on type 'FilterDescriptor | CompositeFilterDescriptor'.

Hi

what is mistake ?

Regards

 

1 Answer, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 01 Feb 2022, 11:25 AM

Hi Masip,

Thank you for providing a runnable example relevant to your request.

It looks like the error is present for the following reason:

this.state.filter.filters in your example is of type CompositeFilterDescriptor.

The filters field of a CompositeFilterDescriptor can be a CompositeFilterDescriptor, but it can also be a simple FilterDescriptor.

Since of these two types, only FilterDescriptor has a field property, TypeScript is giving a warning that essentially a CompositeFilterDescriptor does not have a field property.

To get around the error, the type of the filters property can be narrowed down to a FilterDescriptor, and the error goes away.

Here is a runnable example with the fix (line 128):

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

 

Please let me know if this helps.

Regards,
Georgi
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
Masip
Top achievements
Rank 1
Iron
Answers by
Georgi
Telerik team
Share this question
or