How did you switch from JavaScript to TypeScript?

Ekaterine Mitagvaria - Oct 6 '23 - - Dev Community

How did you switch from JavaScript to TypeScript? I really would love to hear how other people did it.

Why did you do it, what techniques or ways did you use to make it painless and smooth? 😁

I have used TypeScript several times however in React. I was preparing my portfolio for the job hunt and I thought I might need something more. I didn't enjoy it and then didn't use it anymore.

Recently I have seen TypeScript almost everywhere and while planning to hop back to the job hunt again (after trying to find my first job with 300 resumes sent), I decided to take TypeScript more seriously.

I see TypeScript in many job listings, in my country (Georgia), as well as in many European countries and America, not sure about Asia. Seems like I do need it.

So, I decided to start with Vanilla JavaScript, instead of React because I have been targeting Vanilla first to strengthen the fundamentals. Also, I can write code but sometimes have a hard time really explaining it theoretically and that's what I need for interviews.

documentation
First, I spent 2-3 days reading the official documentation and making notes about everything. Then I re-read these notes several times and somewhere at 80% of the documentation I got bored. I am that person who falls asleep when reading. I usually learn faster from practice so I prepared some theoretical knowledge and started converting my JavaScript to TypeScript.

It was horrible! I hardly could use whatever I learned from theory, I forgot everything I wrote down and read and I got stuck. My goal was to try to read, remember, and then try to use that in knowledge. Nope.

In the end, my plan didn't work, I just started learning while fixing all the red lines and googling here and there. The first Vanilla project (very small) took me almost a day to convert to TypeScript because I had to google a lot but also read why I was doing this. I also used ChatGPT a lot to increase the time spent on coding instead of googling and filtering information. Seems like writing 2023 doesn't work for search anymore.

Googling

On the next day, I continued doing the same but then realized most of my projects were on React. So I found random projects on Github and started converting them to TypeScript. And started to become better and better.

My main idea was not to code from scratch and try to come up with all possible case scenarios for TypeScript but instead take the projects already made with Vanilla JavaScript and convert them to TypeScript. And working on other people's projects also could be an additional plus because I learned to read other people's code.

Today is going to be my 3rd day of practice and I was trying to analyze whether it is working or not.

is it working or not

Surprisingly, the case scenarios never end. I learned how to create interfaces but didn't create aliases yet, not sure why haha. Then used a lot of type assertions to work with the DOM, optional parameters, and of course, generics. Getting stuck with asynchronous functions at times but I do feel like it did get better. I am thinking of continuing this way and then switching to React in a similar way.

So, how did you learn TypeScript? Maybe you plan to and you have some great ideas?

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player