打字稿错误2739:**缺少类型**的以下属性

时间:2019-06-19 12:49:54

标签: typescript

键入'{[x:字符串]:PrimitiveValue []; }”缺少“ WordCloudColumns”类型的以下属性:类别,值,排除

power bi自定义视觉单词冲突开源

import powerbi from "powerbi-visuals-api";
import * as _ from "lodash";

// powerbi
import DataView = powerbi.DataView;
import DataViewValueColumns = powerbi.DataViewValueColumns;
import DataViewCategoryColumn = powerbi.DataViewCategoryColumn;
import DataViewCategoricalColumn=powerbi.DataViewCategoricalColumn;
import DataViewCategorical = powerbi.DataViewCategorical;
import PrimitiveValue = powerbi.PrimitiveValue;
import DataViewValueColumn = powerbi.DataViewValueColumn;

export class WordCloudColumns<T> {
    public static getCategoricalValues(dataView: DataView): WordCloudColumns<DataViewCategoryColumn[]> {
        let categorical: DataViewCategorical = dataView && dataView.categorical,
            categories: DataViewCategoryColumn[] = categorical && categorical.categories || [],
            values: DataViewValueColumns = categorical && categorical.values || [] as DataViewValueColumns,
            series: PrimitiveValue[] = categorical && values.source && this.getSeriesValues(dataView);

        return categorical && _.mapValues((new this<DataViewCategoryColumn[]>() as any), (n: any, key: string) => {
            return (<any[]>_.toArray(categories))
                .concat(<any[]>_.toArray(values))
                .filter((column: DataViewCategoryColumn) => column.source.roles && column.source.roles[key])
                .map((column: DataViewCategoryColumn) => column.values)[0]
                || values.source
                && values.source.roles
                && values.source.roles[key]
                && series;
        });        
    }

    // Data Roles
    public Category: T = null;
    public Values: T = null;
    public Excludes: T = null;
}

返回错误,错误消息:

键入'{[x:字符串]:PrimitiveValue []; }”缺少“ WordCloudColumns”类型的以下属性:类别,值,排除

0 个答案:

没有答案