【发布时间】:2017-11-23 20:35:54
【问题描述】:
毕竟这可能是一个非常简单的问题。但是我还没有找到解决方案。
我有一个用签名索引定义的动态对象。通常,所有属性都应该是字符串类型。但也有少数例外。例如,width 应始终为 number 类型。然而,当我将它添加到我的界面时,我得到了错误
error TS2411: Property 'width' of type 'number' is not assignable to string index type 'string'.
这将是我的界面:
interface DynamicStyleObject {
[ key : string ] : string;
width : number;
}
【问题讨论】:
标签: typescript