Enum Type

An enum is special class that represent a group of constants with two flavour "string" and "numeric".
                  
                   //Enum in TS with default numeric value
                    enum Roles {
                      user,
                      admin,
                      super,
                      superAdmin,
                    }

                    //Enum in TS with custom value
                    enum UserRoles {
                      user = 'user',
                      admin = 'admin',
                      super = 'super',
                    }

                    type LoginCredentials = {
                      name: string;
                      email: string;
                      password: string;
                      role: UserRoles;
                    };

                    const user1: LoginCredentials = {
                      name: 'Saten',
                      email: 'saten@demo.com',
                      password: '12345',
                      role: UserRoles.user,
                    };

                    const admin_user: LoginCredentials = {
                      name: 'anshum',
                      email: 'anshume@demo.com',
                      password: '1231213',
                      role: UserRoles.admin,
                    };

                    const super_user: LoginCredentials = {
                      name: 'amson',
                      email: 'mason@demo.com',
                      password: '1231213',
                      role: UserRoles.super,
                    };

                    const isAdmin = (user: LoginCredentials) => {
                      const { name, role } = user;
                      return role === 'admin' ? name : 'He is not admin';
                    };

                    // console.log(isAdmin(user1));
                    console.log(isAdmin(admin_user));