📘 Day 03 of Learning TypeScript — 🚀 Today was all about diving deeper into TypeScript and understanding how TS makes JavaScript safer, cleaner, and smarter. Some major concepts clicked today—especially around type narrowing and type assertions. 🔥 What I Learned Today ✅ 1. Type Narrowing I understood how TypeScript becomes smart based on conditions: 🏹 typeof 🏹 instanceof 🏹 truthiness checks 🏹 switch-case narrowing This helps TS auto-detect whether a value is a string, number, or a specific object type. ✅ 2. Custom Type Guards ✅ 3. Discriminated Union Types Learnt how to create multiple object variations like Masala, Ginger, Elaichi Chai and use the type field for precise narrowing. ✅ 4. Type Assertions (as) Practiced: ✔ Converting any → specific type ✔ Using assertion with JSON.parse() ✔ DOM element type assertion like as HTMLInputElement ✅ 5. Safe Error Handling if (error instanceof Error) to safely access error details. 🧠 Key Takeaway TypeScript isn’t just about types — It’s about making JavaScript predictable, reliable, and professional. Let’s keep going! 💪 #TypeScript #LearningJourney #100DaysOfCode #WebDevelopment #JavaScript #React #DeveloperJourney
Learning TypeScript: Type Narrowing, Guards, and Assertions
More Relevant Posts
-
Day 01 of Learning TypeScript 🚀 Today I covered some core fundamentals of TypeScript, and it already feels like I’m writing cleaner and safer code. Here’s what I learned today 👇 🔹 1. Installation & Setup Installed TypeScript globally Created my first .ts file Used tsc to compile & run the code 🔹 2. Type Inference TypeScript can automatically detect types: let age = 20; // inferred as number This reduces boilerplate and prevents type errors. 🔹 3. Primitive Data Types number string boolean null undefined bigint symbol 🔹 4. Special Types any → flexible but unsafe unknown → safer than any void → used in function void clearly expresses that a function does something but returns nothing. never → for unreachable code 🔹 4. Why avoid any I also learned that any removes all type-checking. Basically, it turns TypeScript back into JavaScript. ❌ Avoid using any unless absolutely required. ✔ Prefer unknown for safer typing. Small takeaway: TypeScript gives structure and catches mistakes before you run the code. Even these basics already feel much more reliable than plain JS. #typescript #javascript #learninginpublic #webdevelopment #frontend
To view or add a comment, sign in
-
🚀 Day 07 of Learning TypeScript — Type Guards & Static Keyword Today I explored two important concepts in TypeScript that make code more robust and structured. 🔹 1. Type Guards Type Guards help TypeScript narrow down types so we can safely work with variables. They make sure we use the right operations on the right type. ✨ Example: function checkValue(value: string | number) { if (typeof value === "string") { console.log(value.toUpperCase()); } else { console.log(value.toFixed(2)); } } 📌 TypeScript understands the type based on conditions like: typeof instanceof 🔹 2. static Keyword in TypeScript The static keyword is used to define properties or methods that belong to the class itself, not to its instances. 📌 No need to create an object to use static methods! ⭐ Key Takeaways ✔ Type Guards make code safer and prevent runtime errors ✔ static helps organize utility methods inside classes ✔ TypeScript keeps improving code clarity and structure Learning step-by-step and enjoying the process 🚀 More concepts coming soon! #typescript #javascript #webdevelopment #learninginpublic #frontend #developers #codingjourney
To view or add a comment, sign in
-
-
Day 47 of the #100DaysOfCodeChallenge Today I started learning TypeScript. Since most modern large-scale applications are moving towards TypeScript, I decided it’s important to understand it properly instead of only relying on JavaScript. Today I explored the fundamentals: What TypeScript is and why it is used How static typing helps catch errors before runtime Basic types like string, number, boolean, arrays, and objects Understanding interfaces and type safety How TypeScript improves code readability and maintainability One thing I realized is that TypeScript doesn't replace JavaScript — it actually enhances JavaScript by adding type safety and better structure, which becomes very useful when working on large or collaborative projects. Right now I’m just getting comfortable with the basics, but I know mastering TypeScript will help me write more reliable and scalable code in the future. 💡 Quote of the day: "The best developers are not the ones who write the most code, but the ones who understand their code the most." Step by step improving the developer toolkit 🚀 #100DaysOfCode #TypeScript #JavaScript #WebDevelopment #LearningJourney
To view or add a comment, sign in
-
-
TypeScript has truly transformed the way I write and maintain code. Adding static typing to JavaScript, it helps catch bugs early—often before they ever reach production. This not only saves time but also boosts my confidence in the code I deliver. One of the things I appreciate most about TypeScript is how it enforces clarity and consistency. It makes debugging easier, improves code readability, and helps maintain high quality as projects grow.
To view or add a comment, sign in
-
-
🚀 Today I Learned: Type Narrowing in TypeScript! TypeScript continues to surprise me with how powerful (and smart) it is! Today, I explored Type Narrowing — a feature that helps TypeScript understand what type a variable holds at runtime, even when multiple types are possible. 🔍 What is Type Narrowing? When a variable has more than one possible type (like string | number), TypeScript uses checks to narrow it down and provide accurate IntelliSense & error checking. 🔧 Ways TypeScript Performs Type Narrowing: typeof checks instanceof checks Equality checks Truthiness checks Custom type predicates 🎯 Why It Matters? Type narrowing makes your code: ✔️ Safer ✔️ More predictable ✔️ Developer-friendly ✔️ Less prone to runtime errors Learning TypeScript step-by-step feels amazing, and type narrowing has definitely leveled up how I write logic in TS! More TypeScript concepts on the way… 🔥 #TypeScript #LearningJourney #WebDevelopment #Frontend #JavaScript #100DaysOfCode #DeveloperJourney
To view or add a comment, sign in
-
-
Just wrapped up learning the fundamentals of TypeScript, and honestly—it’s changed how I think about writing JavaScript 🚀 At first, it felt like extra work 🤯 Adding types, fixing errors I didn’t “need” to fix… but once it clicked, it started saving me time instead of costing it. Here’s what stood out for me: Fewer bugs 🐛❌ → catching mistakes while coding instead of at runtime Better readability 📖 → my code explains itself more clearly Stronger confidence 💪 → refactoring doesn’t feel risky anymore Improved developer experience ⚡ → autocomplete + type hints are a game changer TypeScript doesn’t just make code “safer”—it makes you more intentional as a developer 🧠 Still learning, still building, but definitely glad I added this to my toolkit 🔧 #TypeScript #JavaScript #WebDevelopment #LearningInPublic #DeveloperJourney
To view or add a comment, sign in
-
-
TypeScript isn’t really about types. It’s about trust. As codebases grow, the real problem isn’t writing code. It’s knowing what you can safely change without breaking something else. JavaScript gives you flexibility. TypeScript gives you confidence. clear contracts predictable behavior safer refactoring It doesn’t eliminate bugs. It reduces uncertainty. That’s the difference. In small projects, you might not feel it. In larger systems, it becomes essential. Full breakdown here: https://lnkd.in/gkncNwuU
To view or add a comment, sign in
-
Day 12 of My JavaScript Journey 🚀 Today, I learned about iteration (loops) in JavaScript. I explored: • for loops • while loops I also learned two important statements used in loops: • break: It stops the loop completely • continue: It skips the current iteration and moves to the next Additionally, I practiced: • Looping through arrays • Looping backward • Nested loops (loop inside another loop) To be honest, I don’t fully understand everything yet, but I’m making progress and staying consistent. One thing I’ve realized: Loops require practice to really master. Key takeaway: Consistency and repetition are key when learning complex concepts like loops. #JavaScript #WebDevelopment #LearningInPublic #100DaysOfCode
To view or add a comment, sign in
-
I used to write JavaScript code that worked… until it suddenly didn’t. While building projects, I ran into small but frustrating issues: Passing wrong data types without realizing Undefined values causing errors Bugs that only showed up at runtime That’s when I started learning TypeScript. What I understood is simple: TypeScript doesn’t change how JavaScript works. It helps you catch mistakes before running the code. For example: function add(a: number, b: number) { return a + b; } add(2, "3"); // ❌ Error in TypeScript In JavaScript, this would run (and cause weird results). In TypeScript, you catch it instantly. That’s when it clicked for me: 👉 TypeScript is not about writing more code 👉 It’s about writing safer and predictable code Still learning, but already seeing why many projects prefer it. Have you started using TypeScript yet? #TypeScript #JavaScript #WebDevelopment #Learning #SoftwareEngineering #FullStackDevelopment
To view or add a comment, sign in
-
-
Day 20 — JavaScript Learning Journey Today I focused on understanding how JavaScript handles tasks behind the scenes: Learned the difference between synchronous vs asynchronous code (why JS shouldn’t block execution) Understood callbacks — passing functions to run later Practiced using setTimeout and setInterval for timing tasks Got familiar with the error-first pattern (err, result) Discovered callback hell and why it makes code messy Explored using named functions & async tools to keep things clean and manageable Step by step, things are starting to make more sense. Consistency is the key. 🔑 #JavaScript #WebDevelopment #CodingJourney #Day20 #LearningInPublic
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development