I have a enum as below.
export enum Hotkey {
MARK_IN = 'markIn',
MARK_OUT = 'markOut',
GO_TO_MARK_IN = 'goToMarkIn',
GO_TO_MARK_OUT = 'goToMarkOut'
}
Now i want to create a type for a json object that should allow only the keys present in enum but not some random key during development.
type hotkey = keyof typeof Hotkey;
type clone = {[key:hotkey]: string}
const finalObject: clone = {
MARK_IN : 'markIn'
};
i created the type as above but that is erroring out when i create the type "clone"
Error: An index signature parameter type cannot be a literal type or generic type. Consider using a mapped object type instead.ts(1337)