DEV Community

Cover image for Why Beginners CRUSH IT with TypeScript

Why Beginners CRUSH IT with TypeScript

Sohail SJ | TheZenLabs on November 19, 2024

If you're just starting your coding journey or looking to level up your skills, you might be wondering whether to learn JavaScript or TypeScript. J...
Collapse
 
pengeszikra profile image
Peter Vivo

Typescript is not bad at the end but JSDoc is fare more versatile, compatible with TS, even use TS types from TS module, but can work without compiling. JSDoc vs TS

Collapse
 
asmyshlyaev177 profile image
Alex

JSDoc can't enforce type checks like TS, without enforcing half of the team won't care.
Bigger the team - more benefits from Typescript.
I used to be a TS hater and advocated for JSDoc once.

Collapse
 
pengeszikra profile image
Peter Vivo

JSDoc can also configure to force type check, without extra // @ts-check

Thread Thread
 
asmyshlyaev177 profile image
Alex • Edited

With tsc ? No, thanks, JSDoc is for documentation, can put examples and links there.

Can't put more or less complex types in JSDoc btw, generics for example, maybe on closure compiler only, debug types also harder.

Thread Thread
 
thesohailjafri profile image
Sohail SJ | TheZenLabs

JsDoc can’t replace TS and using it with TS is just great for big teams

Thread Thread
 
pengeszikra profile image
Peter Vivo

JSDoc can use all complex type solution, even generic: (take look this npm module, written in JSDoc)[npmjs.com/package/jsdoc-duck]

Collapse
 
ks_4ef2e5f4b profile image
Kiran Sarpotdar • Edited

Vanilla Javascript is much simpler yet efficient and if one has good programming skills and does coding properly, it's very fast. No need to typecast all variable.s in fact that's strength of JavaScript. Why to add layers on the language which is interpreted and then make it compiled language.

Collapse
 
brense profile image
Rense Bakker

So you get less runtime errors... And yes, that happens a lot. People change function implementations all the time. If some function return type changes and your code that uses that function expects an object with a certain property to be returned and its suddenly not available anymore, you're dead.

Collapse
 
thesohailjafri profile image
Sohail SJ | TheZenLabs

Thats a very good point. TS is must have for such refactoring

Collapse
 
thesohailjafri profile image
Sohail SJ | TheZenLabs

Today only i was building a temporary server. Started with js and then realised i have keep types of functions parameters in check and altered the files to index.js to index.ts 😂😂😂

Collapse
 
c_k_c6c7156c1f991203855d0 profile image
C K

IMO, JavaScript's implicit nature is much easier to learn than TypeScripts explicit nature.

JavaScript's makes it easier for beginners to jump into coding without needing to understand types or deal with strict errors. Especially for smaller projects they are typically working on, TypeScript can feel like over engineering.

I personally stay away from TypeScript because I can write my own JavaScript, thank you. And because I'm cognizant that dynamic typing is not a crutch, but a super power.

This one's obvious. JavaScript's ability to inherently operates without requiring additional type annotations and configurations upfront, which can slow down prototyping.

Also, JavaScript can "Just get it working" quickly, running directly in browsers or environments like Node.js without a compile step like TypeScript requires.

Also, JavaScript's polymorphisms is seamless, built-in without needing to configuring overloads or generics. While TypeScript can do this with any or unions, it's a conscious choice rather than an automatic and natural behavior.

In a nutshell, JavaScript defaults to flexibility and makes it more natural to fit where dynamic behavior is a first-class requirement. Its superpower is the ability to keep things simple and dynamic and never enforce structures unless it is really necessary.

Thanks for the article.

Collapse
 
thesohailjafri profile image
Sohail SJ | TheZenLabs

I agree with your point about the "compile step" and the initial configuration challenges of TypeScript—I’ve spent a fair amount of time getting it right myself.

That said, I don’t see myself going back to JavaScript. TypeScript has saved me from countless bugs, especially those caused by simple typos. And when it comes to refactoring, TypeScript is a game-changer.

I do a lot of refactoring since I’m often the one maintaining the codebase in most of the projects I work on. With TypeScript, I can make sweeping changes confidently, knowing the type system will catch any mistakes.

For me, the upfront investment in setup and learning TypeScript pays off exponentially in the long run, especially for larger or long-lived projects.

Collapse
 
c_k_c6c7156c1f991203855d0 profile image
C K

I completely understand what you're thinking. Long term though, it's a Microsoft language. They will force you to upgrade some historically speaking.

Thread Thread
 
thesohailjafri profile image
Sohail SJ | TheZenLabs

lol so true

Collapse
 
dainiuss profile image
Dainius Stepulevicius

It's easy to forget that just because you are writing typescript it's just same old dodgy JavaScript at runetime with many many weird edgecases!
Not learning Javascript is like saying you are chef if you can make yourself breakfast.

Collapse
 
thesohailjafri profile image
Sohail SJ | TheZenLabs

Cant agree more

Collapse
 
sahil_chaubey_45db49be580 profile image
WebDevWarrior

Great insights! I'm curious, is it worth starting with TypeScript for a small project, or should I stick to JavaScript until I build something bigger?

Collapse
 
asmyshlyaev177 profile image
Alex

Best way to learn is by applying it.

Collapse
 
bugger279 profile image
Inder Sav

I use to hate TS, now I can't imagine going back to JS again. I recommend to start with TS right away.

Collapse
 
thesohailjafri profile image
Sohail SJ | TheZenLabs

Feeling is mutual

Collapse
 
thesohailjafri profile image
Sohail SJ | TheZenLabs

definetly, start small for better trackability

Collapse
 
rushiljalal profile image
Rushil Jalal

Have you ever spent hours debugging a typo or a missing semicolon in your JavaScript code?

I thought JS doesn't require semicolons?

Collapse
 
asmyshlyaev177 profile image
Alex

Semicolon is needed, just most of the times JS can correctly assume it's location, but not always.

Collapse
 
thesohailjafri profile image
Sohail SJ | TheZenLabs

Oh this is new to me. I will keep this in mind

Collapse
 
thesohailjafri profile image
Sohail SJ | TheZenLabs

Thats an optional thing. it works with and without it. I prefer facing without semis

Collapse
 
devops_devrel profile image
Memories From

TypeScript definitely feels like a superpower after reading this! The gradual learning curve you mentioned is such a relief for beginners like me

Collapse
 
thesohailjafri profile image
Sohail SJ | TheZenLabs

Happy that article helped with yo TS journey

Collapse
 
sahil_chaubey_5417dfa7caa profile image
ReactNinja

How long do you think it takes to get comfortable with advanced TypeScript features like generics or utility types?

Collapse
 
thesohailjafri profile image
Sohail SJ | TheZenLabs

For me it took an 6 months window or learning and making, more you build better you get

Collapse
 
sahil_reigns_4776e181e6f7 profile image
ReignsEmpire

You’ve explained why TypeScript is such a game-changer

Collapse
 
thesohailjafri profile image
Sohail SJ | TheZenLabs

hey thanks

Collapse
 
sahilchaubey profile image
sahilchaubey03

The resources you listed for learning TypeScript are gold! Thanks for not just explaining the 'why' but also giving us the 'how' to get started

Collapse
 
thesohailjafri profile image
Sohail SJ | TheZenLabs

Happy that they helped

Collapse
 
armando_ota profile image
Armando Ota

Typescript FTW in JS world since people are writing such a sh*tty code its ridiculous.

Collapse
 
thesohailjafri profile image
Sohail SJ | TheZenLabs

We all start from JS. But yeah I cant imagine myself writing code without TS. Code auto complete and lint as big help avoiding ridiculous typos can make you waste 2 whole days.

Collapse
 
amitind profile image
Amit Yadav

Typescript with deno is also good start where you can just start using typescript without worrying about anything.

Collapse
 
thesohailjafri profile image
Sohail SJ | TheZenLabs

Actually that’s a thought. I haven’t tried deno but i should now

Collapse
 
superdevchaurasia profile image
Ashfak

You mentioned Chakra UI and its TypeScript support—do you think it’s better for beginners than other UI frameworks?

Collapse
 
thesohailjafri profile image
Sohail SJ | TheZenLabs

I definitely think that