Skip to main content

Command Palette

Search for a command to run...

Yes, You Should Use TypeScript

Why you should always pick TypeScript over JavaScript in 2023

Updated
•3 min read
Yes, You Should Use TypeScript
A

Hi, I'm Alex Kates đź‘‹ I'm a product engineer currently working at Croissant as a Founding Engineer. I'm addicted to writing about building, and building things worth writing about. Some extracurriculars include AWS Community Builder Instructor at MIT xPRO Bootcamp Volunteer at Tech for Campaigns

The developer community has been set abuzz by DHH's recent Twitter announcement: Turbo 8 will not be using TypeScript. This has reignited a classic debate among developers—TypeScript or JavaScript?

While the question may seem simple—"Are types really necessary?"—it's a multi-faceted issue that deserves deeper exploration. With that said, let me make a case for TypeScript, a technology that many, including myself, believe brings undeniable advantages to the development experience.

Types Exist: The Unavoidable Truth

Firstly, whether you're an ardent TypeScript supporter or a dyed-in-the-wool JavaScript developer, the undeniable truth is types exist. They form the framework of our coding logic, governing how we interact with variables, invoke functions, and even structure entire programs. Now, the question isn't really about the existence of types, but rather, when do you want to know about type errors?

Catch Errors Early with TypeScript

TypeScript provides the benefit of compile-time type checking. Imagine knowing you have spinach in your teeth before walking into a meeting rather than finding out afterwards. That's what TypeScript offers—a chance to catch and rectify errors early, during development, saving you from the embarrassment of runtime crashes or even worse, production failures.

Sure, you can write unit tests in JavaScript to catch type issues. But then you find yourself asking: why not just use TypeScript in the first place and catch these issues even earlier?

The Rich Developer Experience

Ever had your GPS guide you smoothly around traffic, and thought, "Wow, what did we do before this?" That's what working with TypeScript feels like. The rich IDE support with features like Intellisense and autocomplete not only speeds up the development process but also makes it more accurate and efficient.

Matt Pocock sums this up beautifully in this tweet. The DX of TypeScript is so good that 70% of respondents in the State of JS 2022 said that they use TypeScript over JavaScript.

One Language to Rule Them All

The power of TypeScript shines exceptionally bright when you're dealing with monorepos that include web apps, mobile platforms, APIs, data layers, and even infrastructure as code. Why? Because TypeScript allows you to use one language across your entire stack, and in a type-safe way. This is nothing short of a superpower in the realm of development. Think about it: consistency, reduced context switching, and increased productivity—TypeScript offers all these benefits and more.

I can't imagine, in 2023, building software outside of the TypeScript/monorepo ecosystem. Once you've experienced being able to build a feature, from client to server to infrastructure to database, all in the same repository, in a fully type-safe way, there's no going back.

Community Reactions

The tech community's response to this development has been nothing short of enthusiastic, with many individuals sharing their thoughts and experiences. Here are a few of the most compelling and insightful reactions that I found to be particularly interesting:

Conclusion

While DHH's announcement about dropping TypeScript from Turbo 8 has sparked renewed debate, it also provides an opportunity for reflection. TypeScript isn't just a trend or a buzzword; it's a tool that offers tangible advantages such as early error detection, a more robust IDE experience, and a unified, type-safe language for monorepos.

So, coming back to our original question—do we really need types? With TypeScript, the answer seems to be a resounding "Yes, and they offer so much more!" Whether you view it as a safety net or an enabling superpower, TypeScript stands out as an incredibly valuable tool for modern development.

Comments (13)

Join the discussion
B

TROPICAL DELIGHT RECOVERY IS THE ONLY VERIFIED LICENSE COMPANY.

Are you looking for a way to recover cryptocurrency you misplaced or had stolen? I'm pleased to inform that Tropical Delight Recovery Hacker has resolved the issue that nearly caused my house to fall since I spent the monies my spouse wanted to utilise to start a business. I lost $1.4 million in bitcoin and etherium to these scammers. They excel at what they do and are the leading certified cryptocurrency recovery company. They can be reached instantly at: @ tropicaldelightrecoveryhacker on Telegram and @ tropicaldelightrecoveryhacker.93 on Signal. The email address is TropicalDelightRecoveryHacker @ out look .com.

A

Although I understand the value of TypeScript (TS), JavaScript (JS) is native to the browsers and find it easier to debug than TypeScript. Does it matter? I think depends on the framework you are using. But understand... I despise both of them, just try to pick JS when I can, and if not end up using TS. For framework I do like using VueJS + Vuetify (you can build a nice web application quickly), not a huge fan of React.

10
M

Thank you for the insightful blog post on TypeScript! I especially appreciate your emphasis on the rich developer experience and the ability to use one language across the entire stack. I'm definitely convinced that TypeScript is the way to go for modern JavaScript development.

R

TS

1
N

No, you do not need Typescript. What you need, is a dictionary, that would enlighten you that the definition of "need" is "require (something) because it is essential or very important rather than just desirable.". You need oxygen to live. You don't need TypeScript to live a successful good life. Explicit typing is not necessary nor essential. C, Ruby, Perl, PHP - even PHP - live pretty well without explicit typing. Go tell Facebook that they need strong typing in their PHP, otherwise they won't be happy nor successful, they will make mistakes, and will suffer through all 9 circles of hell. Oh poor Facebook engineers. Yuck. Amazing how hard it is for some people to accept that their mantra might not be the One Universal Truth. Just deal with it. That's the only thing you really need to do in this case.

17
A

Thanks for your comment, Neil.

I feel like I presented a fair argument for why someone should use TypeScript in 2023.

Do you have an argument for why someone should pick JavaScript instead?

I only used the word "need" once in the summary, and I may edit that out because I don't want to be dogmatic about it. This has just been my experience.

N

Alex Kates my quarrel is not about typescript itself, rather about the way this information is being served. "You should do this, because alternatives suck! No, you should do that, because it's better, it's shinier, and it's CPU is 1.4% faster! You absolutely need this new car with automatic parking because you suck at parking, people scratch all the time when they park their cars, don't be like them, buy this new toy with auto parking, don't be like all those fools!". The whole article is one huge marketing preach, borderline religious. And there are very few things is this world that are worse that religious approach to things and believes.

Telling people what they should do or use, what they need or needn't, is bad manners.

You should use the tool that you're the most happy, most comfortable with. Not the most productive, mind you. Leave the "productive" mantra to Silicon people, who don't mind burning out their life, their work, their passion early in the career. You should work with the tool you're enjoying. Even if I hit that nil error with ruby once a year, it still makes me much more happier that Java would. Yes, Types are nice. But that does not matter, if they don't make you enjoy your work. Nothing matters, if you're displeased, unhappy, or straight out hate what you do.

And if some people are happy with JS over TS - awesome! "It would be nice if you'd check out this thing called TypeScript, it may make your life better because this and that. It doesn't mean you should use it. It doesn't mean you need it. But it may make your life easier, so check it out!"

That's - what my point is about.

A

Neil Douglas

I respectfully disagree. This isn't a religious take, but a practical guide for choosing between JavaScript and TypeScript in 2023.

It's a persuasive article, not just personal preference.

While "use the tool that makes you happy" sounds good, it's not practical in a professional setting with real financial stakes.

Why not write an article sharing your own perspective?

N

Alex Kates A guide provides the reader with description, pros, and cons, and leaves the question of choice to the reader.

Marketing pitch convinces the reader that he needs The Thing or that the reader should use The Thing.

This article is trying to convince the reader that he should use The Thing, because using the Alternative is just so much worse. All while being on the entirely one-sided prejudiced approach.

Thus I leave up to the reader to decide if this article is a "guide", or just a blunt marketing pitch of the Thing that Author happened like more than the Alternative, to which Author, along with many others, takes approach with religious-like zealotry.

10
-
--2y ago

I am using typescript, and I regret for using it.

If you support typescript, that means you have not came to a point where typescript becomes pain and you begin to use ts-ignore comments yet

Types may be exist, but world is not perfect, every module has not been written in typescript.

Using TS looks as if it is trying to tame wild JS.

K

Good take on the recent Twitter drama caused by DHH.

I think everyone should take their own decisions about what tech to use that serves their use case.

The whole thing of beef as marketing is something that's worked for DHH previously, so I guess that's what they do.

10
A

Yeaa I tried to stay objective and speak to my experience. Hopefully that comes through.

4
J

Good read. You have legit writing talent!

It's worth noting TS influencers (I hate that that's now a thing in the engineering world) who know nothing about Turbo were freaking out creating internet drama and trashing DHH all while not realizing removing TS changed nothing for the library's users - you don't interface with Turbo through JavaScript. Turbo API is HTML. Removing TS was strictly to make the maintainer's job easier.

Your article... These arguments in support of TS are nothing new and I'm not suggesting they're wrong or bad, but there's strong counter-arguments to these that are universally ignored by folks who feel a strong affinity toward TS. They are:

  • Yes, types already exist in JavaScript - let's use them! And create your own and use those too: if (color instanceof Color) setPaintBrush(color);

  • There are dozens of features built into JavaScript that developers are unfamiliar with and don't use because they have been taught you need TS to do those kinds of things

  • Tests are still 100% necessary. "But it compiled" is a bit of a joke even among strongly typed language communities like Java. It is a common misunderstanding of junior engineers that compiled = no bugs. TS hype reinforces this misunderstanding (not suggesting your article does that, but there's massive amounts of unbridled TS hype out there misleading developers)

  • Intellisense and autocomplete is as good and often better with JSDoc

  • I say better because all the TS projects I have worked on have no comments at all. Developers mistakenly assume typedefs and interfaces tell other developers everything they'll need to know. That's frequently not the case. In healthy codebases TS typedefs ironically have JSDoc comments to provide helpful and necessary information that TS can't, which is shown by intellisense

  • Intellisense and autocomplete is powered by the same ts engine built into the IDE so the developer experience with JSDoc is the same as TS - the UI in my IDE is identical between the two

  • You get type warnings with JSDoc too. Again, it's powered by the same ts engine built into the IDE

  • TS adds bloat to your app bundle

  • TS requires a build step and as such slows down your builds

  • TS requires ongoing configuration and updates, JSDoc requires nothing whatsoever - it's just vanilla JavaScript comments made magical by the IDE

  • TS makes zero guarantees about runtime safety, which is what really matters

  • TS can do nothing about more common bugs like CSS and logical errors

  • I tracked bugs for almost 3 years on a medium-sized app and out of 68 (I think that was the total) only 1 could have been prevented with TS

We need to stop getting emotionally attached to technology. I'm guilty of this too🫣 It's weakening the software engineering culture and it moves important objective facts off the table

12
A

Great Share

11
H

Typescript gona stay here for some time, This js vs typescript trend will be dropped when another hot topic arises.

Meanwhile PHP is dead 🤗.

12

More from this blog

Alex Kates's Blog

33 posts

I'm a product engineer currently working at Croissant as Director of Engineering.

Yes, You Should Use TypeScript