🚀 Chai aur TypeScript – Day 5 Today I learned about Union types and the any type in TypeScript. 🔑 Key Learnings: • Union Types → allow multiple types Example: let id: string | number • Useful in real-world cases like API states pending | success | error • Helps define limited valid options (e.g., seat types: aisle, window, middle) • Any Type → allows any value but should be avoided 💡 Big Insight: Use unions for flexibility with safety, avoid any to maintain type checking #ChaiAurTypescript #TypeScript #JavaScript #LearningInPublic #DeveloperJourney #ChaiCode Hitesh Choudhary Chai Aur Code
TypeScript Union Types and Any Type Explained
More Relevant Posts
-
🚀 Chai aur TypeScript – Day 10 Today I learned about Functions in TypeScript. 🔑 Key Learnings: • Define types for parameters (input) • Define return types (output) • void → function returns nothing • Optional parameters (?) → not required • Default parameters → provide initial values • Handle complex objects using types/interfaces 💡 Big Insight: Clear input and output types make functions safer and predictable #ChaiAurTypescript #TypeScript #JavaScript #LearningInPublic #DeveloperJourney #ChaiCode Hitesh Choudhary Chai Aur Code
To view or add a comment, sign in
-
-
Chai aur TypeScript – Day 11 🚀 Today I learned about Arrays, Tuples, and Enums in TypeScript. 🔑 Key Learnings: • Arrays → define types for elements • readonly → prevent modification • Tuples → fixed types with strict order • Can also be made readonly • Enums → define a fixed set of values • Useful for controlled options 💡 Big Insight: Using strict data structures makes code more predictable and safe #ChaiAurTypescript #TypeScript #JavaScript #LearningInPublic #DeveloperJourney #ChaiCode Hitesh Choudhary Chai Aur Code
To view or add a comment, sign in
-
-
🚀 Chai aur TypeScript – Day 9 Today I learned about Object Types in TypeScript. 🔑 Key Learnings: • Objects can be defined using type or interface • TypeScript follows structural typing (shape matters) • Break complex data into smaller reusable types • Utility Types: Partial → all properties optional Required → all properties mandatory Pick → select specific properties Omit → remove specific properties 💡 Big Insight: Well-structured object types improve code clarity and maintainability #ChaiAurTypescript #TypeScript #JavaScript #LearningInPublic #DeveloperJourney #ChaiCode Hitesh Choudhary Chai Aur Code
To view or add a comment, sign in
-
-
🚀 Chai aur TypeScript – Day 8 Today I learned about Types and Interfaces in TypeScript. 🔑 Key Learnings: • Type Aliases → create reusable custom types • Interfaces → define object structure (useful in OOP) • Union Types → multiple possible values • Intersection Types → combine multiple types • Optional (?) → property not required • Readonly → property cannot be changed 💡 Big Insight: Using types and interfaces makes code more readable, reusable, and safe #ChaiAurTypescript #TypeScript #JavaScript #LearningInPublic #DeveloperJourney #ChaiCode Hitesh Choudhary Chai Aur Code
To view or add a comment, sign in
-
-
🚀 Chai aur TypeScript – Day 7 Today I learned about Type Assertion, unknown vs any, and the never type. 🔑 Key Learnings: • Type Assertion → tell TypeScript the exact type Example: value as string • unknown vs any → unknown is safer, requires type checking • never type → represents values that should never occur • try-catch → use instanceof Error to safely access error properties 💡 Big Insight: Prefer unknown over any and use type assertions carefully Hitesh Choudhary Chai Aur Code #ChaiAurTypescript #TypeScript #JavaScript #LearningInPublic #DeveloperJourney #ChaiCode
To view or add a comment, sign in
-
-
🚀 Chai aur TypeScript – Day 6 Today I learned about Type Narrowing and Type Guards. 🔑 Key Learnings: • unknown → safer than any (requires type checking) • typeof → used to narrow primitive types • instanceof → used for class-based checks • Truthy checks → ensure value exists before using • Custom type guards → validate object structure • switch / conditions → handle all possible cases 💡 Big Insight: Always narrow the type before using the data to ensure safety #ChaiAurTypescript #TypeScript #JavaScript #LearningInPublic #DeveloperJourney #ChaiCode
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
-
-
Ever written explicit type annotations for simple literals like 'production' or 3000? 🤔 TypeScript 6.0 now infers these automatically! Previously, TypeScript would infer `string` for 'production' and `number` for 3000, forcing explicit annotations for precise types. With TypeScript 6.0's enhanced literal type inference, you get precise literal types automatically, reducing boilerplate while maintaining type safety. → No more verbose annotations for simple constants → Better autocomplete and type checking → Cleaner, more readable code What's your favorite TypeScript 6 feature so far? 🚀 #TypeScript #TypeScript6 #JavaScript #WebDevelopment #CodingTips
To view or add a comment, sign in
-
-
👩💻 We built this in bootcamp with a professor walking us through it. I then decided to rebuild and upgrade it alone. The original was vanilla JavaScript + the OMDB API. It worked, but it was guided every step of the way. ⚙️ This time I upgraded it to React & TypeScript figuring out on the way what to change and why. ✨ Additional features that I added: – Favourites saved directly on the same page via localStorage – TypeScript to keep the data handling clean and intentional Turns out the best challenge after finishing a bootcamp is going back and doing it again, without a safety net. 🔗 Link: https://lnkd.in/eSXMHEKv #developerjourney #react #typescript #javascript
To view or add a comment, sign in
-
-
A Live Admin Panel Without Writing JavaScript: Curling IO's admin area is a single Lustre server component running on the BEAM. One WebSocket connection, one long-lived Erlang process per session. Every interaction goes over that WebSocket and comes back as a DOM patch. The page never reloads, and there's no client-side JavaScript framework. The entire admin UI is written in Gleam, compiled to Erlang, and runs server-side. https://lnkd.in/eGwQ4aGx
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