Enumerating my shortcuts:
export enum Hotkey {
MARK_IN = 'markIn',
MARK_OUT = 'markOut',
GO_TO_MARK_IN = 'goToMarkIn',
GO_TO_MARK_OUT = 'goToMarkOut'
}
I am now looking to define a type for a JSON object that validates only keys present in the enum, rejecting any random key entries during development.
type hotkey = keyof typeof Hotkey;
type clone = {[key:hotkey]: string}
const finalObject: clone = {
MARK_IN : 'markIn'
};
Upon creating the "clone" type as shown above, I encountered the following error:
Error: An index signature parameter type cannot be a literal type or generic type. Consider using a mapped object type instead.ts(1337)