Why People Avoid TypeScript
Seems overkill for personal projects.
Or maybe you’re experienced enough that you already know how to avoid common JS pitfalls. You don’t get the “aha” of types.
Let me start by telling you, “I get it.” I was there too. It wasn’t until my friend @TejasKumar_ helped me migrate one of my JS projects to TS that I finally understood the hype around static types. It gave me a whole new level of confidence in my programming.
My goal for today is to talk through some of my favorite aspects of TypeScript and convince you to try it for your next project.
Show me the code
If you want to see a basic example in TypeScript, take a look at this TypeScript Playground link.
Why I Love TypeScript
Now that I’ve used TypeScript in my default stack for the past 4 years, I know exactly what I love about it.
I feel more confident
I’m more productive
When my IDE understands what types I’m working with, it gives me autocomplete and it’s beautiful. Remember in school when your English teacher would mark up your paper with red ink?
TypeScript does exactly that inside your IDE. It yells at you when you pass in the wrong type. And most of the time, it tells you how to fix it! That means you fix issues while you’re developing rather than after pushing to prod. I can’t tell you how much time it’s saved me. Faster feedback loop means less time crushing bugs and more time shipping features. Now that’s efficiency for you.
My code is self-documenting
This is probably the top feature for me in TypeScript. My code documents itself. You can look at it and know exactly what it wants and what it returns thanks to static types. I find myself writing fewer comments over the years because most of it is self-explanatory.
Most IDEs will show you this information on hover or you can “Jump to definition” and see where the types are defined. This means it’s 10x easier to debug third-party libraries written in TypeScript as well. Boom boom. Win-win for you and the future you forgetting all the code you wrote last month.
- TypeScript Course: free 3-module email course
- Total TypeScript: free video tutorials with coding challenges
- TypeScript videos on egghead
Today I shared my favorite parts about TypeScript with you in hopes that it becomes part of your default toolkit. For me, it’s helped me write safer, more maintainable code faster than before. I use TypeScript both at work and for personal projects and can’t imagine going back to JS.
But don’t let this article convince you - set a timer for 5 mins and try it yourself. It’s best to experience it first-hand.
Last thing, I'll be holding "TypeScript Office Hours" where you can:
- get advice
- do code-reviews
- teach me something
- get project feedback
- talk about imposter syndrome
- learn about contributing to open source
Sign up here 👉🏼 https://savvycal.com/typescript-course/chat