Logo

dev-resources.site

for different kinds of informations.

Typescript enum vs. "as const"

Published at
10/4/2023
Categories
ts
typescript
enum
asconst
Author
aburd
Categories
4 categories in total
ts
open
typescript
open
enum
open
asconst
open
Author
5 person written this
aburd
open
Typescript enum vs. "as const"

This is not a post where you learn anything. For those who want to learn, please see yourself to the exit. For those looking for unadulterated opinions from an old man yelling at clouds, then you've come to the right place.

This whole enum vs. "as const" debate is incredibly tedious and has done nothing except to further the social stock of pedants in the Typescript blogosphere. Because of this "debate" every few weeks I'm forced to opine about which one a like more or which one would fit better or which one is "bad" or which is convention, etc. The list of minor reasons goes on and on and talking about it really feels like discussing where we'd like certain grains on sand on the beach to be. A.K.A. I don't care.

Now it's not to say that people don't do this with the best of intentions. I get it, you want the code to be readable, refactorable, etc. And for this, you should be lauded. Too many times, I've seen code that is truly a nightmare because the people writing it didn't have time or didn't care enough to put some thought into it. But...I've got to say, spending days discussing how best to write a switch-statement will not move the ball as much as you think it will and most of this energy can be put towards bigger questions.

Conclusion

Typescript team, if you're listening, the truth is I don't know how to fix this. If the solution were easy, there wouldn't be > 300 issues on Github. But dear god, please do something and release me from these boring conversations.

ts Article's
30 articles in total
Favicon
How to improve the Frontend part of the project using one button as an example :))))
Favicon
Azure App Service doesn't returned compressed (gzip) files for Angular application?
Favicon
Deploying a Simple Static Website on AWS with CDK and TypeScript
Favicon
Understanding Next.js and TypeScript Tutorial
Favicon
🛠️📚 Classes with TypeScript - a cheat sheet
Favicon
Event Loop in 2 Minutes
Favicon
How Boring It Is to Write Articles or Talk to Certain Types of Developers These Days.
Favicon
How ts-pattern can improve your code readability?
Favicon
isNaN vs Number.isNaN
Favicon
🛠️ 📦 TypeScript Generics - a cheat sheet
Favicon
TypeScript Generics: How to Write Flexible and Type-Safe Code
Favicon
Introduction to TypeScript
Favicon
Dominando os Utility Types do TypeScript
Favicon
Nega aynan Vue.js ?
Favicon
TS-BoilerplateX
Favicon
What Are Standalone Components Angular 17 ?
Favicon
Navigating the JS TS Limbo
Favicon
Demystifying TypeScript Generics with Simple Examples
Favicon
Typescript enum vs. "as const"
Favicon
Mastering TypeScript: A Comprehensive Tutorial
Favicon
m3u8 to mp4 with merged audio
Favicon
Shouldn't an NPM package that helps hundreds of thousands of programmers increase their productivity tenfold be open-sourced?
Favicon
ChatGPT: how I used it to convert HTTP requests to OpenAPI document
Favicon
Cleaning up unused Typescript Files with `ts-prune`
Favicon
Intern's Guide Chat GPT Full Stack: Nest, React, Typescript
Favicon
Using LiteFS with Bun on Fly.io
Favicon
Know your users' location in React Ts
Favicon
Regex #1: Understanding Regex, Regex-Based String Methods and Regex Flags
Favicon
The Witcher Card Game Live
Favicon
Powerful File System manager for Nodejs

Featured ones: