【发布时间】:2021-08-25 01:51:39
【问题描述】:
interface Foo {
bar: {};
[key: string]: string;
}
// Property 'bar' of type '{}' is not assignable to string index type 'string'.
我正在尝试使属性bar 是Object 并且任何其他属性都是字符串,如何在没有any 的情况下定义它?
【问题讨论】:
-
请参阅this question 及其对围绕此类“默认”或“休息”索引签名问题的回答。从该答案翻译代码会产生this。祝你好运!
标签: typescript typescript-typings