Skip to content
0:00 / 0:00

#typescript#enums#typescriptenums

Let's Talk About TypeScript's Worst Feature

Theo - t3․gg

576K subscribers • 11 videos on Hallway

YouTube
  • Recommended by 2 people: 2 in engineering communities.
  • Presented by Theo Browne, creator of t3.gg
  • An opinion. It argues one side of a question engineers disagree on.

Intermediate. Assumes working knowledge.

56K views3 years ago2 recommendations

Programming languagesWeb developmentTypeScriptJavaScript

Theo Browne explains why enums are considered TypeScript's worst feature and why developers should use alternative patterns like union types.

Please tell me you're not still using enums. Let's leave them behind in 2022. #t3stack #fullstack #webdevelopment ALL MY VIDEOS ARE POSTED EARLY ON PATREON patreon.com/t3dotgg Everything else (Twitch, Twitter, Discord & my blog): t3.gg/links S/O Mir for the awesome edit 🙏

Why it's here

2 people recommend this

What people say. Recommended as a clear explanation of the pitfalls of TypeScript enums and why to avoid them.

u/MercyHealMePlsin r/typescript • Recommends

On “What's up with all the enum hate lately?”

…. However in that case I'd personally still just use an object. const defaultNames = { max: 'Max', julia: 'Julia', } let name: string = defaultNames.max; // and later... name = 'Sara'; I don't want you to think that I absolutely hate enums. I just never use them because they don't benefit me. I recently saw a link to this video by Theo from T3 where he explains why he doesn't like enums, that's how I got aware of the fact that I'm actually not the only one avoiding them. I think he has usually really good takes on most things and has some interesting opinions, but I think the point he's making about enums specifically isn't really that well thought through. That's…

u/Ok_Lavishness9265in r/Frontend • Recommends

On “interview question prep question”

I personally avoid using enums (apart of if you're planning to loop through it (as in \`Object.keys(COLOR\_ACTION).forEach((key) => console.log(key))\`. So I'd rather have \`type ColorAction = 'darken' | 'invert'\`. That might be just a taste thing, although there can be more thoughts put into it too: [video [video I'm also not a fan of inline object typing as you have in \`{color}: {color: Color}\`. If there is only 1 key in this object, why not just take the parameter as \`color: Color\`?