Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法将动态值设置为Js.tReScript 中的键?
Js.t
不,这不对。Js.t是一种在编译时所有键都已知的类型。因此,无法在运行时添加或删除键。Js.Dict.t是一种也表示为 JavaScript 对象的类型,它允许在运行时添加或删除键。这里的权衡是所有值都需要具有相同的类型,并在给定的类型参数中编码Js.Dict.t。
Js.Dict.t