type ValueOf = T[keyof T]; interface Product { id: string; name: string; price: number; inStock: boolean; } // Example Usage: type ProductValues = ValueOf; // Expected: string | number | boolean const idValue: ProductValues = "prod-123"; const nameValue: ProductValues = "Laptop"; const priceValue: ProductValues = 1200; const inStockValue: ProductValues = true; // This would cause a type error: // const unknownValue: ProductValues = new Date(); // Another example: const userRoles = { admin: 'Administrator', editor: 'Editor', viewer: 'Viewer', } as const; // 'as const' makes properties readonly and values literal types type UserRoleLiteral = ValueOf; // Expected: 'Administrator' | 'Editor' | 'Viewer' const role1: UserRoleLiteral = 'Administrator'; const role2: UserRoleLiteral = 'Viewer'; // const role3: UserRoleLiteral = 'Guest'; // Type error