我有这两种类型:
type ArbitraryPropertyName = keyof typeof arbitrary;
type D = { [k in ArbitraryPropertyName]: any };
现在我想声明一个 的变量type D
,但我不想一个一个地分配每个 absolutePropertyName ,像这样:
const d: D = {
arbitraryPropertyName1 = ...,
arbitraryPropertyName2 = ...,
...,
arbitraryPropertyNameN = ...
}
有没有办法为每个属性动态分配一个值?