DevExpress Typescript Field Type ts(2345)

41 views Asked by At

I am trying to add some fields to create date groupings, but I am getting a type error.

let dateGroups: {
    area: string;
    dataField: string;
    dataType: string;
    groupInterval: string;
}[]
Argument of type '{ area: string; dataField: string; dataType: string; groupInterval: string; }' is not assignable to parameter of type 'PivotGridDataSourceField'.
  Types of property 'area' are incompatible.
    Type 'string' is not assignable to type '"column" | "data" | "filter" | "row" | undefined'.ts(2345)

And here is my code:

let dateRollupFields = this.pibotGridSource.fields();
const createdAtIndex = dateRollupFields.map(o => o.caption).indexOf("Created At");
let dateGroups = [{
        area: 'column',
        dataField: 'created_at_date',
        dataType: 'date',
        groupInterval: 'month'
      }, {
        area: 'column',
        dataField: 'created_at_date',
        dataType: 'date',
        groupInterval: 'year'
      }]

dateRollupFields.splice(createdAtIndex + 1, 0, dateGroups[0]);
1

There are 1 answers

0
mochaccino On

Annotate dateGroups as an array of PivotGridDataSourceField.

let dateGroups: PivotGridDataSourceField[] = [{

You should be able to import the type from pivot-grid.