【发布时间】:2021-12-30 09:35:48
【问题描述】:
我想反转具有唯一常量属性值的记录的属性名称和类型。
const VALUE = {
field1: "fieldA",
field2: "fieldB"
} as const
type Reversed = Reverser<typeof VALUE>
//which should yield the following type
type Reversed = {
fieldA: "field1";
fieldB: "field2";
}
我认为这是不可能的,因为属性值不一定是唯一的。但我还是问了 ;-)
【问题讨论】: