DEV Community

Jason Shimkoski
Jason Shimkoski

Posted on • Edited on

Don’t Overthink It; Typescript Isn’t Scary

A few years ago, when I first delved into the world of strongly-typed JavaScript, I absolutely hated it.

Don’t get me wrong, I didn’t hate the concept of it. I didn't mind the sometimes obtuse type errors it spits at you, that it was perceived to be difficult to learn, or even the corporation pushing it. It was the setup process and the excessive configuration necessary at the time that made me want to chew on marbles.

When I have an idea or a project that I want to work on, I just want to...well, work on it! Not configure it.

Nowadays, with enhancements to build tools (Vite specifically), that headache, thankfully, is all but extinct.

With a couple of terminal commands, you have a complete Typescript-ready workspace that is not only a joy to use, but it is faster than starting with a basic httpd server and an index.html file.

Now that the configuration junk is no longer an issue, you would think you could finally get to work.

Then, it happens… you stumble upon your first type error. When you do, like everyone does, you Google it.

Suddenly, you are assaulted by blog post after blog post written by people making Typescript seem way more complicated than it really is.

You cower in the corner with tears streaming down your face, wondering how you could possibly ever memorize all of the utility types.

You start to assume everything needs a class decorator for some reason, and you start begging your fellow coders for answers to riddles like, “What the hell is the difference between String and string?"

You then kneel and pray to Gozer to make it past your first battle with any.

Image description

Back up! Slow down! It’s not that complicated. Nine times out of ten, all you need to do is examine your code and ask yourself what you are actually trying to accomplish.

Once you do that, the type, or interface that you need to define will jump out at you. Define it based on what your code is trying to do and go from there.

Before you know it, your code editor will spring to life. You’ll get auto completion, jumping to definition functionality, and documentation for what you’re writing as you are writing it.

Once this miracles occurs, you realize that all of the fear you once had was unfounded.

You’ll find that when you start small and with the basics, the scary factor of Typescript vanishes and you’re left with an amazing coding experience.

If you can get past the initial projection that Typescript is tough, and just make it easy, you’ll be rewarded.

Top comments (0)