【发布时间】:2021-01-12 08:04:23
【问题描述】:
我需要这样的东西:
interface IMyInterface {
Payload?: object;
[key: string]: boolean | string | number | Date;
}
但上面的代码给了我以下错误
“对象”类型的属性“有效负载”| undefined' 不能分配给字符串索引类型'string |号码 |布尔值 |日期”。
有没有办法通过interface 或type 实现我想要的类型?
【问题讨论】:
标签: typescript