enum keyEnum {
firstKey = 1,
secKey = 2,
thirdKey = 3
};
enum firstPropEnum {
a = 'a',
b = 'b',
};
enum secPropEnum {
c = 'c',
d = 'd',
};
type firstAndSecPropEnum = firstPropEnum | secPropEnum;
type keyPropObj = {
[keyEnum.firstKey]: { prop: firstPropEnum },
[keyEnum.secKey]: { prop: secPropEnum },
[keyEnum.thirdKey]: { prop: firstAndSecPropEnum },
};
type getKeyProp<T extends keyEnum> = keyPropObj[T]['prop'];
type getKeyPropResult1 = getKeyProp<keyEnum.thirdKey | keyEnum.secKey> // Result secPropEnum | firstPropEnum
// Expected Result secPropEnum.
type getKeyPropResult2 = getKeyProp<keyEnum.thirdKey | keyEnum.firstKey> // Result firstPropEnum | secPropEnum
// Expected Result firstPropEnum.
type getKeyPropResult3 = getKeyProp<keyEnum.secKey | keyEnum.firstKey> // Result firstPropEnum | secPropEnum
// Expected Result never;
So i was expecting to get an intersection rather than a union. The Result should be a value that in common among all the resulting props. Any help on the same would be highly appreciated.