This type only works with simple object types without nested structures or complex types. It may not behave as expected with objects containing nested properties, union types, intersections, or other advanced constructs.
For example, given a simple object type T
:
type SimpleObjectType = {
name: 'Zee';
age: 29;
city: 'Zion';
};
type T = KeysToValues<SimpleObjectType> // results in:
{
Zee : 'name';
29: 'age';
'Zion': 'city';
}
Infers a mapping from values to their corresponding keys within a given object type
T
. The resulting type provides a reverse lookup, which allows to to retrieve the keys based on specific values.