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?
Top comments (30)
As everyone says Typescript i will play the other side “I would pick javascript”
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.
Javascript can get types and interfaces with adding JSdocs, and it works really well.
“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.
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)
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.
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.
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.
Yes Typescript - Typed JavaScript at Any Scale.
C#
orJava
Big Tech Companies like Google , Slack , Airbnb have migrated their code base from Javascript to Typescript
typescriptlang.org/
No. This is a jungle. You want a banana, but got a jungle. Dependency everywhere: code editor, plugins, devDependencies, dependencies, build tools.
Keep it super simple!
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.
By far, Typescript.
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.
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.
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.
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.
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.
For almost everything, yes.
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 🤝.
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.
Typescript wherever possible
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.
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.