const fruitCounts = {
apple: 12,
banana: 23
}
type PropUnion<T extends Record<PropertyKey, any>> = {
[K in keyof T]: {
[K2 in K]: T[K2]
}
}[keyof T]
type FruitCounts = PropUnion<typeof fruitCounts>
标签:Typescript,union,object,K2,keyof,type
From: https://www.cnblogs.com/Answer1215/p/16730648.html