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/
By far, Typescript.
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.
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.
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 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.
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.
Typescript wherever possible