Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace enums with object "as const" #774

Open
ezra-sg opened this issue Feb 14, 2024 · 0 comments
Open

Replace enums with object "as const" #774

ezra-sg opened this issue Feb 14, 2024 · 0 comments

Comments

@ezra-sg
Copy link
Contributor

ezra-sg commented Feb 14, 2024

enums should not be used in typescript code and are considered to be a code smell / bad practice. we should replace enums with objects using the as cost keyword

e.g.

export enum Sort {
    ascending = 'asc',
    descending = 'desc',
}

// replace with
export const Sort = {
    ascending: 'asc',
    descending: 'desc', 
} as const;

see https://www.youtube.com/watch?v=jjMbPt_H3RQ&t=410s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant