相关疑难解决方法(0)

"请考虑使用映射对象类型." - 什么是映射对象类型,我如何在这里使用它?

interface Foo { 
    [foo: "hello" | "world"]: string;
}
Run Code Online (Sandbox Code Playgroud)

我收到一条错误消息

An index signature parameter type cannot be a union type. Consider using a mapped object type instead.
Run Code Online (Sandbox Code Playgroud)

什么是映射对象类型,以及如何使用它?

typescript

24
推荐指数
2
解决办法
4267
查看次数

标签 统计

typescript ×1