Consider the following scenario:
enum MouseType {
GENERAL_USE = 1,
SPECIALIZED_USE = 2,
}
enum KeyboardType {
GENERAL_USE = 3,
SPECIALIZED_USE = 4,
}
interface MouseSpecifications {
buttons: number;
dpi: number;
}
interface KeyboardSpecifications {
keys: number;
}
type Data = {
[key in MouseType | KeyboardType]: MouseSpecifications | KeyboardSpecifications;
}
What modification can be made to Data so that the last entry results in an error?
const information: Data = {
[MouseType.GENERAL_USE]: { buttons: 4, dpi: 800 }, // valid
[MouseType.SPECIALIZED_USE]: { buttons: 6, dpi: 1600 }, // valid
[KeyboardType.GENERAL_USE]: { keys: 78 }, // valid
[KeyboardType.SPECIALIZED_USE]: { keys: 120 }, // valid
[MouseType.GENERAL_USE]: { keys: 999 }, // should not be valid
};