Today! We’re going to learn TypeScript like you’re a smart 5-year-old who loves to build things and asks “why?” (which is the best thing ever).
& yes “why?” is my way of learning.
I've divided this into 20 Chapters. and will go one by one and each will be of 2 - 3 min. of read.
This is Chapter ⓵ TS Mastering
🧩 Chapter 1: What is TypeScript and Why Should I Care?
🤔 Imagine this:
You’re building a toy robot (Yes, we are learning it like 5) . In JavaScript, you just glue parts together however you like even if you accidentally attach a banana instead of a motor… the robot won’t complain until it breaks later! 🍌🤖💥
But with TypeScript, it’s like having a smart helper who says:
“Hey! That’s not a motor... that’s a banana. Are you sure you want to do that?”
That helper saves you from mistakes before you even turn on the robot. Cool, right?
🛠️ So... what is TypeScript?
TypeScript = JavaScript + Superpowers (called Types)
It’s made by Microsoft to help developers write safer, smarter code.
- TypeScript helps you catch errors early
- It makes your code easier to understand
- It works great with modern tools and editors
💬 Let’s look at a simple example:
// JavaScript
function add(x, y) {
return x + y;
}
add(5, "10"); // 🙃 oops! This gives "510" instead of 15!
Now in TypeScript:
function add(x: number, y: number): number {
return x + y;
}
add(5, "10"); // ❌ ERROR! You gave me a string, I wanted a number!
TypeScript tells you before you even run it that something’s wrong.
🤔 But wait… can I still write normal JavaScript?
Yes‼️ TypeScript is just JavaScript with extra safety.
If you know JS, you already know most of TS. We just add type annotations.
🪄 Why Should You Care?
- 🐞 Catch bugs before they happen
- 👯♂️ Work better in teams
- 💻 Get amazing auto-suggestions in your code editor
If you enjoyed this and want to master TypeScript and other technologies, follow the series and drop a like!🤝
I’m a passionate software developer sharing the cool things I discover, hoping they help you level up on your coding journey.
Read More : Rethinking State Management in React — From a Dev, for Developers.
Top comments (0)