A new milestone in my life

Tim Mouskhelichvili
Tim Mouskhelichvili
1 minute to read

Hello, my dear friends! I hope you and your families are doing well.

This update will be short.

Last weekend was my birthday. I am now 28.

I am slowly approaching the thirties club.

And I am not depressed about it (for now haha).

Tip of the week

In today's tip of the week, I want to talk about why I don't use TypeScript enums and what I use instead.

TypeScript enums implementation has many problems:

  • Enums increase the size of the payload.
  • They are challenging to iterate over.
  • They are useless at runtime.

So what do I use instead? I use an array with const assertion.

Here is an example:

typescript enums

This solution is easy to understand, simple to iterate over, and usable at runtime!

You can use the Roles type to validate types and roles to validate inputs.

Cool right?

Articles

I added two new articles on the axios npm library:

Thank you for reading.

See you next week!

Tim M.

Comments (0)
Reply to:
Page content
  1. Tip of the week
  2. Articles