Ever struggled with figuring out how to deal with undefined? Or spent a good cup of coffee (and a half) to stop the Typescript compiler from screaming at you? In Typescript we often come across values that can have multiple values, called union types, and in some cases one of those values is undefined. If […]
“I love Typescript, but I hate the configuration”
Back upright, posture checked, fingers have just been cracked, you’ve got some good music playing and you’re ready to sit down and start coding on your new cool idea. Whilst ideas begin to unfold in your mind and you’re about to burst with creativity you envision “hey, this would be a cool opportunity to get […]
How to manage consistent types using extract
As we start unfolding Typescript and start to maintain an ever-increasing amount of types in our codebase, we might want to start doing things smarter at some point. I’m a very pragmatic person and that makes me subscribe to the idea of DRY; especially when it comes to managing types. I really do not want […]
Enabling ESM with TS, without the headaches
This post was written from an optimistic standpoint, enabling ESM and TS on a new project, making it a straight forward thing to do.If you’re migrating an existing codebase, see my recent article on that topic right here, as that’s a much harder thing to do. Are you wanting to get on the latest trend […]
How to properly use a .d.ts files
If you’ve ever need a global type to be available or perhaps already have a few, then There are several cases in Node where we may want to extend interfaces, a common such example is when using the library passport that often recommends appending a user object to our express Request object. Using Typescript, this […]
Taking the ‘Patch’ Out of Monkeypatching: Adding Properties in TypeScript
Let’s dive in. It’s a common scenario. You’re coding away in TypeScript, enjoying the safety net of static types. Then, you hit a snag. You need to attach a new property to an existing object, and TypeScript, in all its type-safe glory, is telling you, “Nope, sorry, that’s not going to happen.” In your case, […]
How to fix “Uncaught ReferenceError: process is not defined” error
Ever run into this dreaded issue when working with Javascript or – preferably – Typescript?Nothing is more frustrating than happily coding away, deciding you want to increase the security abstraction layer a bit – or perhaps you subscribe to the 12 Factor App – only to get met with this error. Thankfully, you’ve come to […]
The dreaded JS-to-TS Migration: Partial progress or full migration?
I write a lot about Typescript. I write a lot about why I think it’s better than Javascript. And perhaps I’ve convinced you too! Maybe you want to start converting some JS projects to TS and see what the fuzz is all about. The only thing blocking you is… How the hell do I get […]
Why pure functions are just better in TS
When writing code in TS there are various design choices and patterns that we use, some occurring on purpose and others just happening with little or no thought. One such example is “pure functions” a concept from Javascript that is in my opinion, even more important in Typescript. Pure functions are a simple concept that […]
TS Debugging that doesn’t suck
Unfortunately, at some point or another you are going to create a bug in your system. The larger it grows the more likely it is that you will create that bug. Or an exception! Lean more on how to deal with those here. So what do we do about it? Well, we need to arm […]