타입스크립트의 enum은 아직 완벽하지 않습니다.
enum Role {
USER,
GUEST,
ADMIN,
}
enum Role2 {
USER = 'USER',
GUEST = 'GUEST',
ADMIN = 'ADMIN',
}
function changeUserRol(rol: Role) {}
function changeUserRol2(rol: Role2) {}
changeUserRol(2);
changeUserRol(4);
// Argument of type '4' is not assignable to parameter of type 'Rol'.
changeUserRol2(Role2.USER);
changeUserRol2('USER');
// Argument of type '"USER"' is not assignable to parameter of type 'Rol2'.