如何在Typescript中用字符串键和特定对象类型写入对象的类型?

时间:2017-09-26 03:12:12

标签: typescript types interface

export type Distributions = {
    [index: string]: {
        distributions: Array<number>,
        histogramUpperLimit: number,
        nonZeroUser: number,
        percentiles: Array<number>
    }
};

let test: Distributions = {
    "thisIsAID": {
        distributions: 1238
    }
};

它应该抛出错误,但它没有,我写的不正确?

0 个答案:

没有答案