export const masterKeysObject = {
MAIN: 'main',
REDIRECT: 'redirect',
DASHBOARD: 'dashboard',
USER_ID_PARAM: ':userId',
CREATE_NEW: 'create_new'
} as const;
type MasterKeys = keyof typeof masterKeyObjects;
const allowedKeys: (keyof typeof masterKeysObjects)[] = [
'DASHBOARD',
'CREATE_NEW',
// Add other allowed keys as needed
];
export const onlyAllowedKeysObject: Record<typeof allowedKeys[number], string> = {
DASHBOARD: 'Dashboard',
CREATE_NEW: 'Create New',
};
This solution is not functioning properly.
An error is occurring:
Type '{ DASHBOARD: string CREATE_NEW: string;}' does not include the expected properties like 'ROOT', 'DEFAULT_REDIRECT', 'USER_ID', 'ACCOUNT_ID', and more.ts(
Is it possible to write TypeScript code that ensures the keys of onlyAllowedKeysObject
are a subset of the masterKeysObject
?