Preserve Literals

Preserve Literals
πŸ‘¨β€πŸ’Ό We store role permissions in a configuration object. Without as const, TypeScript widens the booleans to boolean, which loses useful information.
🐨 Open
index.ts
and:
  1. Add as const to the roles object
  2. Create a Role type using keyof typeof roles
  3. Fix the adminCanDelete assignment
  4. Implement canDeleteUsers using the roles data
πŸ’° as const preserves true and false as literal types, not just boolean.

Please set the playground first

Loading "Preserve Literals"
Loading "Preserve Literals"
Login to get access to the exclusive discord channel.
Loading Discord Posts