anmol-kansal.hashnode.devImplement ReturnType<T> Utility Type from Scratch in TypeScriptHey there, TypeScript tinkerers! 👋 Ever thought about how doesReturnType<T> works under the hood? Today we’re going to build our own version of ReturnType<T> from the ground up, so you can see how it works under the hood. Let’s dive in! Why do I nee...Jun 17, 2025·2 min read
anmol-kansal.hashnode.devWhy TypeScript Fails to Infer Types in Your Switch StatementsTypeScript’s type inference system is incredibly powerful — but it also has strict rules designed to keep your code predictable and safe. Sometimes, those rules can feel overly cautious. A common example? Using a switch statement with discriminated u...Apr 18, 2025·3 min read
anmol-kansal.hashnode.dev🔄 Global State in React Without Context API or External LibrariesManaging the global state is a common challenge in React. While tools like Redux, Zustand, or even React’s built-in Context API are popular choices, they can sometimes feel like overkill for simpler use cases. What if you could share the state betwee...Apr 5, 2025·2 min read
anmol-kansal.hashnode.devImplementing a Polyfill for Promise.allSettled() in JavaScriptIntroduction When working with multiple asynchronous operations in JavaScript, you may want to wait for all of them to complete—regardless of whether they resolve or reject. That’s where Promise.allSettled() comes in! Unlike Promise.all(), which fail...Mar 28, 2025·3 min read
anmol-kansal.hashnode.dev🚀 Implementing a Polyfill for Promise.all in JavaScriptPromise.all is a powerful built-in helper function in JavaScript that takes an array of promises and returns a new promise that resolves when all the given promises have resolved or rejects if any promise fails. But have you ever wondered how you can...Mar 15, 2025·2 min read