@coding_with_mrm
Coding With Mr.M
7 days
Never use enums in TypeScript. But here's why I've moved away from them: 1. They don't tree-shake well (adds runtime code) 2. They create numeric values that cause subtle bugs 3. They don't work with string literal unions properly What I use instead:
1
0
0

Replies

@coding_with_mrm
Coding With Mr.M
7 days
const Status = { PENDING: 'pending', APPROVED: 'approved', REJECTED: 'rejected', } as const; type Status = typeof Status[keyof typeof Status]; Same type safety. Better tree-shaking. No runtime surprises. The TypeScript team themselves rarely use enums in their codebase
0
0
0