🛑 TypeScript doesn’t make your API responses safe This is how we usually do it: 🔹You define a type for the API response 🔹You fetch the data 🔹You assign the type to it And it feels safe But it’s not! 🚫 TypeScript does not validate runtime data It only trusts what you tell it So, if your API returns the wrong shape, your app can still break That means validating the data before trusting it Even a simple check is better than none Below is a simple snippet that uses a Type Predicate to validate the API response before consuming it 👇 Are you validating your API responses or just trusting them? #programming #typescript #code #javascript #api #backend
TypeScript API Response Validation
More Relevant Posts
-
TypeScript devs explaining why you should rewrite everything in TypeScript: "Type safety!" "Catches bugs at compile time!" "Better autocomplete!" "Refactoring is so much easier!" Cool. How long did you spend defining interfaces for a function that returns a string? "...2 hours." Meanwhile JavaScript devs wrote the entire feature, shipped it, got user feedback, and iterated twice. Does TypeScript catch bugs? Yes. Does your 500-line type definition file prevent runtime errors? No. Will TypeScript devs care? Absolutely not. Both languages are incredible. But treating every project like it's a banking system is how you end up debugging generic constraints at 2 AM for a landing page. Use the right tool. Not the safest one. #TypeScript #JavaScript #Programming #DevLife #TechTwitter
To view or add a comment, sign in
-
-
TypeScript told you everything was fine. It lied. 8pm. Your phone buzzes. Slack from the CTO. "Something is broken in prod." You open the logs. undefined is not a function. But... the types were correct. You checked. TypeScript didn't complain. Then you see it. Someone used as SomeType three PRs ago to shut up the compiler. The API returned something different. TypeScript never saw it. It always is. TypeScript makes JavaScript safer. It doesn't make it safe. The gap is real. And it always shows up at the worst possible time. Rust makes a different promise. If it compiles, the type contract holds. Everywhere. Always. No casting your way out. No any as escape hatch. No "it should be fine" at 2am. That's a different guarantee entirely. Follow me. #rust #typescript #javascript #programming
To view or add a comment, sign in
-
🚀 Why TypeScript is a Game-Changer for Developers If you're working with JavaScript and not using TypeScript yet, you're missing out on something powerful! Here’s why developers are rapidly switching to TypeScript 👇 🔹 Static Typing Catch errors early during development instead of debugging later. 🔹 Better Code Quality TypeScript helps you write cleaner, more predictable code. 🔹 Enhanced IDE Support Get powerful auto-completion, suggestions, and better tooling support. 🔹 Improved Maintainability Makes large-scale applications easier to manage and refactor. 🔹 Scalability Perfect for building complex and enterprise-level applications. 💡 TypeScript is not just a language, it's a developer productivity booster. 👉 Are you using TypeScript in your projects? Share your experience! github link https://lnkd.in/g5pKZjQQ #TypeScript #JavaScript #WebDevelopment #MERN #Coding #Developers #Programming
To view or add a comment, sign in
-
-
🚀 Day 973 of #1000DaysOfCode ✨ Ultimate Guide to TypeScript TypeScript has become a must-have skill for modern developers — but many people still struggle to connect all the pieces together. In today’s post, I’ve shared an ultimate guide to TypeScript that covers everything from basics to advanced concepts in a structured and easy-to-understand way. From types and interfaces to generics, utility types, and real-world usage patterns — this guide is designed to give you a complete understanding of how TypeScript works. This is not just about syntax — it’s about writing safer, scalable, and more maintainable code in real-world applications. Whether you’re a beginner getting started or an experienced developer looking to level up, this guide will help you build strong TypeScript fundamentals. 👇 What’s the most challenging TypeScript concept for you right now? #Day973 #learningoftheday #1000daysofcodingchallenge #FrontendDevelopment #WebDevelopment #JavaScript #TypeScript #CodingCommunity #Programming
To view or add a comment, sign in
-
Just diving deeper into TypeScript, and I'm blown away by how it transforms JavaScript development. 🚀 Here's what makes TypeScript a game-changer: 📌 **Static Type Checking** — Catch bugs before runtime. No more mysterious undefined errors! 📌 **Better IDE Support** — Autocomplete and refactoring that actually understands your code 📌 **Self-Documenting Code** — Types act as built-in documentation. Anyone reading your code knows exactly what to expect 📌 **Scalability** — Makes large codebases manageable and maintainable 📌 **OOP Features** — Classes, interfaces, and access modifiers for structured development For anyone on the fence about learning it: the investment pays off. Your future self (and your team) will thank you. #TypeScript #JavaScript #WebDevelopment #Learning
To view or add a comment, sign in
-
🚀 Day 966 of #1000DaysOfCode ✨ Interface vs Types in TypeScript (Explained Simply) If you’ve worked with TypeScript, you’ve probably seen both `interface` and `type` — and wondered which one to use. In today’s post, I’ve broken down the difference between interfaces and types in a simple and practical way, so you can understand their real use cases. While both are used to define the shape of data, they behave differently when it comes to extension, flexibility, and advanced use cases like unions and intersections. Understanding when to use `interface` and when to use `type` can make your code more scalable and easier to maintain — especially in large applications. This is one of those concepts that often comes up in interviews and real-world projects. If you’re using TypeScript in your workflow, having clarity on this will level up your code quality. 👇 Do you prefer using `interface` or `type` in your projects? Why? #Day966 #learningoftheday #1000daysofcodingchallenge #FrontendDevelopment #WebDevelopment #JavaScript #TypeScript #CodingCommunity #Programming
To view or add a comment, sign in
-
We're back with another update on react-infinite-scroll-component(https://lnkd.in/gZgRuSkG)! 🥁 When I took over as maintainer, I laid out a 4-phase roadmap to bring this library back to life. Today, we're crossing off Phase 2 with the release of v7.0.0. 🎉 Here's where we stand: ✅ Phase 1 — Comprehensive test suites & CI/CD automation (v6.1.1) ✅ Phase 2 — React 17 migration (v7.0.0) 🔜 Phase 3 — TypeScript conversion & modern React features 🔜 Phase 4 — Accessibility improvements & enhanced documentation What shipped in v7: - React 17 peer dependency support - Jest + React Testing Library test coverage - Storybook upgraded from v5 to v7 - Revamped CI/CD with automated publish workflows - ESLint, Prettier, and Husky configured for contributor-friendly DX - Node.js 18+ baseline 109k+ dependents. Still going. Still breaking nothing. Huge thanks to Ankeet Maini for the trust, and to everyone who's filed issues, opened PRs, or just starred the repo, your patience means a lot. I'll be actively going through open issues and PRs now, so if you've been waiting, your turn is coming. 🙌🏻 #OpenSource #React #JavaScript #TypeScript #WebDevelopment #Community #Maintainership
To view or add a comment, sign in
-
I just started learning TypeScript… and I came across something really useful It’s called Partial a TypeScript utility type. Here’s what it does It takes an existing type and makes all its properties optional. So instead of rewriting a type when you only want to update some fields… type User = { name: string; email: string; password: string; }; type UpdateUser = Partial<User>; Now UpdateUser can accept any of those fields not all of them. What is it used for? It’s perfect for: • Updating user data (you don’t need to send everything) • Forms where some fields are optional • APIs where partial updates are allowed Basically… anytime you don’t need the full object. Simple, but really powerful. Still learning, but TypeScript is already making things cleaner If you’re learning too, let’s grow together #typescript #webdevelopment #frontenddeveloper #javascript #codingtips #softwaredeveloper #devcommunity #learncoding #programminglife #codebetter #devtips #100daysofcode #buildinpublic #techcontent #programmerlife #webdev #cleancode #softwareengineering #frontend #CodingTips
To view or add a comment, sign in
-
-
React prop types and TypeScript - type safety matters, yaar! PropTypes are runtime type checking. TypeScript is compile-time type checking. Both have their place, but TypeScript is generally preferred for new projects. Benefits of TypeScript: - Catch errors before runtime - Better IDE support - Self-documenting code - Easier refactoring If you're using JavaScript, at least use PropTypes in development. It helps catch bugs early. Also, define clear prop interfaces/types. Don't use `any` everywhere - that defeats the purpose. Be specific about what your components expect. Type safety = Fewer bugs = Happier developers = Better code! 🎉 Are you using TypeScript or PropTypes? #reactjs #webdevelopment #javascript #typescript #frontend #coding #typesafety #programming #indiancoders #tech
To view or add a comment, sign in
-
🛑 TypeScript doesn’t make your API responses safe This is how we usually do it: 🔹You define a type for the API response 🔹You fetch the data 🔹You assign the type to it And it feels safe But it’s not! 🚫 TypeScript does not validate runtime data It only trusts what you tell it So, if your API returns the wrong shape, your app can still break That means validating the data before trusting it Even a simple check is better than none Below is a simple snippet that uses a Type Predicate to validate the API response before consuming it 👇 Are you validating your API responses or just trusting them? #Typescript #React #Frontend #WebDevelopment #Javascript #ProgrammingTips #FrontendDevelopment #Coding #CodingTips
To view or add a comment, sign in
-
More from this author
-
RxJS in Angular — Chapter 6 | Error Handling — Building Apps That Don't Break
Jack Pritom Soren 3w -
RxJS in Angular — Chapter 5 | Subject, BehaviorSubject & ReplaySubject — The Two-Way Radio
Jack Pritom Soren 4w -
RxJS in Angular — Chapter 4 | switchMap, mergeMap, concatMap — Observables Inside Observables
Jack Pritom Soren 1mo
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
a bit of a overkill, but if the api is crucial to your app then this is a great tip :)