Kendo ui TypeScript定义,其中属性类型已知,但名称不为**

Kendo ui TypeScript定义,其中属性类型已知,但名称不为**,kendo-ui,typescript,Kendo Ui,Typescript,因此,我正在努力将剑道UI库的部分内容转换为TypeScript,但我仍停留在模型类上。问题在于字段的指定方式 给定以下数组: function someModelFields() { return { Id: { editable: false, nullable: false, defaultValue: emptyGuid }, ScenarioId: { editable: false, nullable: false, defaultValue

因此,我正在努力将剑道UI库的部分内容转换为TypeScript,但我仍停留在模型类上。问题在于字段的指定方式

给定以下数组:

 function someModelFields() {
    return {
        Id: { editable: false, nullable: false, defaultValue: emptyGuid },
        ScenarioId: { editable: false, nullable: false, defaultValue: emptyGuid },
        UnitId: { editable: false, nullable: false },
        UnitNumber: { type: "string", editable: false },
        SquareFootage: { type: "number", editable: false }
    };
};
…如果属性名称可以是任何内容,但属性的类型是已知的,我将如何在TypeScript中对此进行建模?以下是我到目前为止的情况:

export module Kendo {

    export module Data {

        export class FieldTypeEnum {
            static string: string;
            static number: string;
            static boolean: string;
            static date: string;
        }

        export class ValidationDefinition {
            required: bool;
        }

        export class FieldDefinition {
            defaultValue: string;
            editable: bool;
            nullable: bool;
            parse: () => any;
            type: FieldTypeEnum;
            validation: ValidationDefinition;
        }

        export class ModelDefinition {
            id: string;
            fields: any[];
        }
我知道“字段”的定义是错误的,我知道在ModelDefinition.fields和FieldDefinition类型的dynamic propertyname之间缺少一个类型


想法?提前谢谢

在TypeScript中,除了您已经拥有的以外,实际上没有其他方法可以对其进行建模