DEV Community

Cover image for Why I'm Learning Typescript
Anna Baker
Anna Baker

Posted on

Why I'm Learning Typescript

One of the things that I like most about TypeScript is that it is a superset of JavaScript. This means that any valid JavaScript code is also valid TypeScript code. This makes it very easy to get started with TypeScript. Another thing that I like about TypeScript is that it has static typing. This means that you can catch errors at compile time, rather than at runtime. This makes for much more stable and robust code.
One of the challenges that I have faced while learning TypeScript is understanding the type system. The type system in TypeScript is very powerful, but it can also be quite complex. It has taken me some time to get a good understanding of it, but I am still learning new things about it all the time.
Overall, I am really enjoying learning TypeScript. It is a great language that has already helped me to improve my JavaScript skills. I am looking forward to continuing to learn more about it and using it in my future projects.

What is Typescript?

TypeScript is a free and open source programming language developed and maintained by Microsoft. It's a typed superset of JavaScript that compiles to plain JavaScript. TypeScript adds optional types, classes, interfaces, enums, generics, and more to JavaScript. These features can be used by the TypeScript compiler to provide type safety for your code. TypeScript code can be compiled to ECMAScript 3, ECMAScript 5, or ECMAScript 6 (also known as ES2015) code.
If you're familiar with React, you may have used the createreactapp CLI tool to create a new React project. The createreactapp tool uses TypeScript by default. This is because React is developed using TypeScript and it's recommended that you use TypeScript for React projects.
TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. It gives you type safety, objectoriented programming, and other benefits that the JavaScript language lacks. If you're familiar with React, you may have used the createreactapp CLI tool to create a new React project. The createreactapp tool uses TypeScript by default. This is because React is developed using TypeScript and it's recommended that you use TypeScript for React projects.

Why I'm Learning Typescript

I've been meaning to learn Typescript for a while now. I'm finding it really helpful in understanding JavaScript concepts, and it's also just really fun to use. I'm looking forward to using it more in the future.
I first heard about Typescript when I was looking for ways to improve my JavaScript skills. At the time, I didn't really understand what it was or how it worked, but the idea of being able to type out my code and have better control over my variables sounded appealing. After doing some research, I decided to give it a try and I've been hooked ever since.
Typescript is a superset of JavaScript, which means that any valid JavaScript code is also valid Typescript code. This makes it easy to get started with, as you can gradually add Typescript features to your existing code base without having to rewrite everything from scratch.
One of the things I love about Typescript is that it forces you to be more explicit about your code. For example, if you try to access a property on an object that doesn't exist, you'll get an error. This might seem like a pain at first, but it actually saves you a lot of time in the long run by catching errors early on.
Another great thing about Typescript is the support for type annotations. This allows you to specify the type of a variable, which can be helpful for catching bugs before they happen. For example, if you have a function that expects an number as an argument, you can annotate the function with:

function(num: number) { ... }

If someone tries to call this function with a string instead of a number, they'll get an error telling them that they're using the wrong type of argument. This is extremely useful for catching errors in large codebases where there are many different types of data being passed around.
Overall, I'm really enjoying learning Typescript and I'm looking forward to using it more in the future. It's helped me improve my JavaScript skills and has made me more aware of potential errors in my code. If you're thinking about learning Typescript, I would highly recommend it!

How I'm Learning Typescript

I'm currently using the TypeScript Deep Dive book as my primary resource for learning Typescript. This book does a great job of explaining all of the features of Typescript in a clear and concise manner. Additionally, the book includes a number of exercises that help to reinforce the concepts that are being taught.
In addition to the TypeScript Deep Dive book, I've also been using the official TypeScript documentation as a reference. The documentation is extremely thorough and covers every aspect of Typescript in great detail. While it can be a bit daunting at first, it's a great resource to have on hand when you need to look up something specific.
I've also been making use of online resources such as the TypeScript Playground (https://www.typescriptlang.org/play/) and the TypeScript Handbook (https://www.typescriptlang.org/docs/handbook/). These resources are extremely helpful for trying out code snippets and seeing how various features of Typescript work.

Overall, I'm finding that learning Typescript is not as difficult as I initially thought it would be. With the help of some great resources, I'm slowly but surely getting up to speed with this powerful programming language.

Latest comments (55)

Collapse
 
youssefmic profile image
Youssef-mic

Hello, for me learning typescript is largely unnecessary because I work alone and I hate oop maybe you can say I am biased but doesn't matter I am ok with javascript as it is

Collapse
 
annabaker profile image
Anna Baker

Thank you for your opinion! I respect that you are happy with JavaScript as it is, and as long as you are ok with that's great! For me, I find that learning TypeScript is helpful because it forces me to think about my code in a different way. I also enjoy the challenge of learning something new. :)

Collapse
 
youssefmic profile image
Youssef-mic • Edited

Thanks a lot

Collapse
 
elsyng profile image
Ellis • Edited

Imho, ts is not a language. It's a "typing+" tool for js. And as such, I find adding some ts features into your js is good. Ts has a lot of obscure features, which I think do more harm than good. I think one should not try to apply all ts features religiously. But that's me :o)

One very big benefit of React (for instance) is, it allows you to use js / ts minimally, I find.

Collapse
 
annabaker profile image
Anna Baker

I agree, ts is a good tool, but that one should not try to use all of its features all of the time.

Collapse
 
beraliv profile image
beraliv

Hey!

Thank you for the article!

If you didn't see github.com/type-challenges/type-ch..., you can give it a try, it helped me a lot in the last several years. Especially helpful if you want to dive into challenges and learn more things in details.

The only thing that I didn't like is the lack of detailed explanation

Collapse
 
annabaker profile image
Anna Baker

Thank you so much for the kind words! I'm glad you found the article helpful.

I'm always looking for ways to improve my writing, so I appreciate your feedback.

Collapse
 
deinnalynch profile image
DeinnaLynch
Collapse
 
lexiebkm profile image
Alexander B.K.

My reason for learning TS :

  1. Angular uses it. Although I am still using React, Angular is still interesting to learn (and use).
  2. NestJs uses it. As a Node.js framework), NestJs is heavily inspired by Angular for the architecture. However, because I am still learning TS, I suspend my learning this Node.js framework, until my knowledge in TS is adequate.
  3. Several other useful/interesting libraries use it.
Collapse
 
annabaker profile image
Anna Baker

It's great that you're learning TS! I'm sure you'll be able to use it in many different frameworks and libraries. Keep up the good work :)

Collapse
 
chrishunterjohnson profile image
Chris Hunter-Johnson

I like typescript - the only issue I have is getting it to work with the Theme file for material-ui

Collapse
 
apimike profile image
Mike Rozner

Simply put, it's a great article.

Collapse
 
annabaker profile image
Anna Baker

Thanks!

Collapse
 
polenj86 profile image
Maciej

Hi,
I also struggled at the beginning when I started learning typescript, it might be annoying at the beginning but now after 3 years of using it I'd never go back to vanilla JS, I simply love the fact of finding errors at compile time instead of finding them at runtime.
Anyway everyone should use it because it makes you think "better" on your code

Collapse
 
annabaker profile image
Anna Baker

You're so right! It can be frustrating at first, but learning typescript is so worth it in the end. It's helped me write much cleaner and more error-free code.

Collapse
 
eshimischi profile image
eshimischi
Collapse
 
joelbonetr profile image
JoelBonetR 🥇

Thank you, never heard about that, seems useful for learning purposes and toying around (I'm not confident enough on mutators to use that in a serious project though 😅)

Collapse
 
vishalraj82 profile image
Vishal Raj

Good. Here is the typescript boilerplate repo
dev.to/vishalraj82/getting-started...
Hope this helps.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.