DEV Community

Cover image for Do you prefer TypeScript over vanilla JS?

Posted on

Do you prefer TypeScript over vanilla JS?

TypeScript is a superset of JavaScript that extends it by adding data types, classes, and other object-oriented features with type-checking.

As far as I've tried it, I would say I liked it and I could surely see the additional features being useful in more complex code bases.

What's your opinion on TS? Do you use it wherever possible (by default) or do you still prefer to write vanilla JS?

Discussion (30)

hjorthbjorn profile image
Björn Hjorth • Edited on

As everyone says Typescript i will play the other side “I would pick javascript”

  1. Javascript does not need to be transpiled, it runs straight in the browser. One quickly forgets the joy of just refreshing the browser and it’s there. Saving and waiting for everything to get done is one of my worst productivity killers.

  2. Javascript can get types and interfaces with adding JSdocs, and it works really well.

  3. “Always bet on Javascript” is a phrase that is used a lot and it still holds true to day. Many of the issues that come from Javascript can be fixed with writing good code.

  4. Javascript Is much easier to get in to and learn for beginners. Right click and check the source. Or just run that command straight in the web browsers console.

“If” Typescript was native to the browser I would pick Typescript any day, but until that day I will say Javascript is my go to language. (At least for the browser)

baldore profile image
Camilo Orrego

It's good to see that you go with JavaScript, and I don't want to go against all your points, just the first one: there's no modern project that just uses JavaScript in the browser. At least you will need to use Babel to have all the features in any project, or something like Webpack.

hjorthbjorn profile image
Björn Hjorth

Agree any project worth there salt has a build pipeline. But a thought is to keep the dev experience as vanilla as possible and use the pipelines for builds to prod.

Where I work we do nothing of this, it’s a giant enterprise solution with all the bells and whistles that comes with it.

So this is just a pipedream for less pipelines.

stojakovic99 profile image
Nikola Stojaković

I agree. Beside that, TypeScript allows gradual move from JS to TS code base and build times are not slow at all, even for the bigger projects.

shaijut profile image
Shaiju T • Edited on

Yes Typescript - Typed JavaScript at Any Scale.

  • Static Typing avoids Typos
  • Maintenance of Large Code Base is made easy by references
  • Its feels easy to code fast, as though you are coding in C# or Java

Big Tech Companies like Google , Slack , Airbnb have migrated their code base from Javascript to Typescript

patoi profile image
István Pató

No. This is a jungle. You want a banana, but got a jungle. Dependency everywhere: code editor, plugins, devDependencies, dependencies, build tools.

  • Write well-written JavaScript: use guards, objects, write tests.
  • Do not create "Large Code Base"! Design modular architecture, use microservice/microfronend. Think big, act small.
  • TypeScript is a syndrome: lack of architecture design. Yeah, big companies can fail in it.

Keep it super simple!

manchicken profile image
Michael D. Stemle, Jr.

I prefer ES6 JavaScript by a lot. TypeScript adds a lot of complexity without any major runtime benefit. It also limits the more dynamic capabilities of JavaScript, mostly to solve problems of carelessness.
There's also a huge performance suck in TypeScript in how people convert one "type" to another, simply to mitigate the type validation system introduced by TypeScript.

jwp profile image
John Peters

By far, Typescript.

king11 profile image
Lakshya Singh

I do really like the autocompletion and error checking we get but sometimes it's really hectic to resolve some typescript error and I have been facing a lot of trouble with mongoose and typescript integration ;__; if someone can help with that please do.

ayoisaiah profile image
Ayooluwa Isaiah

TypeScript makes it really easy to refactor code. You change the type of a value and the build will break, this makes it really easy to know all the places that need to be updated.

Also for auto-completion goodness and correctness checks. So yeah, I prefer to use TypeScript when starting new projects.

bassochette profile image
Julien Prugne

It is not really a question of preference.
I am a lazy developer and typescript allow me to write less tests and ensure code quality.
So by default I use typescript.

twigman08 profile image
Chad Smith

After doing a few different projects in both TypeScript and JavaScript, I am pretty much TypeScript everything.

Not only do I feel comfortable about knowing basic typos will be found, I find it just so much easier to fully navigate a new project.

The only time it becomes a little annoying is if I know I have to use some small library that doesn’t have any types made out yet. So then I do have to make the choice am I going to go through the library and figure out how everything is done and make some types myself, or just do the last resort and just declare a type module that is type of any. But I usual try to avoid those libraries, or I just create basic types as I see I will need them for the library.

aslasn profile image

I've heard the its very hard to find people who once migrated to typescript and didn't like after a while and switched back. Even if they not liked it much or it didn't interested them much or it was annoying at first. That made me switch to typescript and I'm now even migrating my old active projects to typescript.

juliang profile image
Julian Garamendy

For almost everything, yes.

codefinity profile image
Manav Misra

A senior dev advised that I should focus on learning TS b4 worrying so much about the unit tests. I didn't initially agree, but having embraced TS recently, I now see 👀 his point, and agree 🤝.

endymion1818 profile image
Ben Read

Yes. Love it and cannot go back. In my experience it takes much less time to debug than fixing the errors you’d get without it.

arunmurugan78 profile image
Arun Murugan

Typescript wherever possible

themartes_ profile image
Matej Bunček 🤔 • Edited on

As you say " I could surely see the additional features being useful in more complex code bases.". JS is unmaintainable on larger projects. That's why I/we are using TS in work because it's easier to understand. When you hop on the project, and everything is typed, under interfaces and so on, it's really easy to understand the codebase. However, I can't say this about JS. You have to figure out what's going, what sometimes takes a while. I'm using also JS on personal projects, but for the projects, I'm planning to maintain and return to I'm using always TS.

eljayadobe profile image

I wrote a very large program in TypeScript, and I think it has only gotten better since then. For small programs... well, meh. But for medium or larger programs, it has got the Right Stuff.

stojakovic99 profile image
Nikola Stojaković
alexanderop profile image
Alexander Opalic

Typescript is the way

codebyjustin profile image

TypeScript makes everything easier for me.

promikecoder2020 profile image


jonrandy profile image
Jon Randy

No. No no no no no no no no no no no no. No. No


rvxlab profile image

What is your reasoning as to why not? As someone who loves and embraces TypeScript I'm very curious.

feliperes profile image

Can I use typescript to get the type of external framework objects? If yes, I will change to it now!

kais_blog profile image

It depends. Frameworks written in TypeScript export their types directly. For others, e.g. express, the type definitions are provided by the community. You can download them via npm i -D @types/express. For lesser known libraries there might be no type definitions available.

ndaidong profile image
Dong Nguyen

After all, JavaScript is still my choice. I want to keep my dev workspace as simple as possible, with native JavaScript, VIM, HyperApp... and the small toys like that.

kalashin1 profile image
Kinanee Samson

I like TS but I only use it when the task at hand is complex, and I want the additional safety and organization TS offers, however for simple tasks I prefer using vanilla js

aaditya profile image
Aaditya Chakravarty

I like TypeScript but If I have to compile the code into JS in the end, might as well code in JS