enum keyEnumNew {
firstItem = 1,
secItem = 2,
thirdItem = 3
};
enum firstEnum {
x = 'x',
y = 'y',
};
enum secEnum {
m = 'm',
n = 'n',
};
type firstAndSecEnums = firstEnum | secEnum;
type keyObject = {
[keyEnumNew.firstItem]: { value: firstEnum },
[keyEnumNew.secItem]: { value: secEnum },
[keyEnumNew.thirdItem]: { value: firstAndSecEnums },
};
type getKeyValue<T extends keyEnumNew> = keyObject[T]['value'];
type getKeyValueResult1 = getKeyValue<keyEnumNew.thirdItem | keyEnumNew.secItem> // Result secEnum | firstEnum
// Expected Result secEnum.
type getKeyValueResult2 = getKeyValue<keyEnumNew.thirdItem | keyEnumNew.firstItem> // Result firstEnum | secEnum
// Expected Result firstEnum.
type getKeyValueResult3 = getKeyValue<keyEnumNew.secItem | keyEnumNew.firstItem> // Result firstEnum | secEnum
// Expected Result never;
It was anticipated that the outcome would be an intersection rather than a union. The expected result is a value common to all resulting properties. Any assistance on this matter would be greatly appreciated.