Opinions on code style preference in a library project I'm working on for enum replacements

So for the sake of boredom and seeing a lot of content related to enums lately pop up, I asked myself. "Hey, can I make a better version of enums?" And the truth is, I have no idea but its been an interesting journey to try to figure out. The bulk of the idea is fleshed out for my generative enums and the final step is probably adding support for custom object shapes rather than a transformative string or incremental index. However before that, I was just wondering if I could get some thoughts on preference in code style, especially in a library aiming to replace something as simple and concise as enum.
export const Roles = Enum(3, "User", "Admin", "Owner"); // Type: { User: 0, Admin: 1 , Owner: 2 }
export type Roles = Extract<typeof Roles>; // 0 | 1 | 2
export const Roles = Enum(3, "User", "Admin", "Owner"); // Type: { User: 0, Admin: 1 , Owner: 2 }
export type Roles = Extract<typeof Roles>; // 0 | 1 | 2
export const Roles = makeEnum(3, "User", "Admin", "Owner"); // Type: { User: 0, Admin: 1 , Owner: 2 }
export type Roles = ExtractEnumType<typeof Roles>; // 0 | 1 | 2
export const Roles = makeEnum(3, "User", "Admin", "Owner"); // Type: { User: 0, Admin: 1 , Owner: 2 }
export type Roles = ExtractEnumType<typeof Roles>; // 0 | 1 | 2
export const Roles = makeEnum(3, "User", "Admin", "Owner"); // Type: { User: 0, Admin: 1 , Owner: 2 }
export type Roles = ExtractEnum<typeof Roles>; // 0 | 1 | 2
export const Roles = makeEnum(3, "User", "Admin", "Owner"); // Type: { User: 0, Admin: 1 , Owner: 2 }
export type Roles = ExtractEnum<typeof Roles>; // 0 | 1 | 2
export const Roles = Enum(3, "User", "Admin", "Owner"); // Type: { User: 0, Admin: 1 , Owner: 2 }
export type Roles = Enum<typeof Roles>; // 0 | 1 | 2
export const Roles = Enum(3, "User", "Admin", "Owner"); // Type: { User: 0, Admin: 1 , Owner: 2 }
export type Roles = Enum<typeof Roles>; // 0 | 1 | 2
How do I weight the benefits and drawbacks of convenient naming versus more descriptive naming? Also added disclaimer, I understand that I am probably not replacing enums for anybody else in the world, but I was bored and thought it would be a fun project and I'm actually a huge fun of the results given that my types are unions and my intellisense still operates flawlessly I'm kind of leaning toward the last option but I am really curious the direction others would take
0 Replies
No replies yetBe the first to reply to this messageJoin