Happylab Logo
Published on

Day01: Why I Want to Learn TypeScript

Authors

Day01: Why I Want to Learn TypeScript


Introduction

This is an overdue introduction. About a year after switching careers, I kept hearing the name TypeScript and wondered what it was. Is JavaScript going to die? I just started learning it. Later, I learned that it is a strongly typed version of JavaScript, which made me feel a bit relieved. I thought to myself: "I can learn it later," and then I became lazy and still haven't learned it.

As for why I decided to stop being lazy and participate in this challenge, I was quite surprised myself. I am very grateful for the encouragement from the great people I met at the web lab event at the end of last year, which gave me the courage to push myself a bit.

At first, I thought of many topics I wanted to learn, such as improving my React skills, implementing D3.js, Three.js, writing APIs, etc. After watching a recent JSDC live stream titled "Should Modern Projects Introduce TypeScript?", I immediately decided to dive in and learn TypeScript. So, it's time for front-end developers to learn TypeScript.


What Can TypeScript Do?

So, what can TypeScript do? Let's refer to the slides from the JSDC presentation by Bo Ge:

❓ This is a mistake that everyone has probably made. Did you see the error in the following image?

. . .

🙄 It's just a typo, missing an s. Sometimes, even if an error is reported, you still can't find it. JavaScript is a free spirit; you never know what object you're dealing with. It's fun to write, but debugging can be a headache.

✅ The following image shows how to use TypeScript's interface to define the type of an object, allowing you to immediately know the errors during development, reducing a lot of debugging time.


My TypeScript Learning Journey

Generally, I will refer to the official TypeScript handbook for learning, as well as Bo Ge's beginner's guide and articles from other experts. I will learn in a relaxed manner, hoping to get through 30 articles!

My learning directions include:

  1. TS environment installation + automatic compilation
  2. tsconfig.json TS initialization configuration
  3. Three methods of specifying types in TS
  4. TS data types
    • Primitive types
    • Object types
    • Types unique to TypeScript (there are many)
  5. TS Interfaces
  6. What is Narrowing?
  7. Generics
  8. Functions
  9. Classes
  10. Interfaces & Classes
  11. Modules
  12. React + TypeScript applications

My writing skills are not great, so I will treat this as notes. I will also refer to documents, and not all content is original. If there are any copyright issues or errors, please feel free to point them out. Thank you very much!

PS: I suddenly saw a joke the day before the competition, found it very funny, and decided to entertain myself—hope it brings you a smile 😊


References

https://www.youtube.com/watch?v=n_M7m21m7EY