Author: Martin Aarhus Gregersen

Understanding ‘this’ in Builder classes

Builder classes are an interesting pattern. Originating from the OOP world, they seem to have found a good place in the Javascript (and Typescript) ecosystem. Builders can be incredibly helpful in assisting us in creating complex objects, often step-by-step. They are at their best in code-bases where we often need similar, yet different, complex objects […]

How to tell Typescript a function always returns something

Nothing is more frustrating than having the Typescript compiler complain about something that obviously worked fine in Javascript, what the hell man!? However, as frustrating as it seems, Typescript is actually trying to protect us from… Well, ourselves! Sometimes we know more than Typescript and we can safely ignore such warnings, for example by declaring […]

Type safety and generics do not have to be complicated!

Ever find yourself consuming a third party library, or API, with Typescript? Ever been in a situation where whatever you’re working with, isn’t exactly strongly typed, entirely neglecting one of the advantages of Typescript? Me too! But fret not, there are things we can do to ensure type safety even when working with libraries, objects […]

Some reasons to stick with Javascript instead of using Typescript

There are many reasons that a developer may want to stick with Javascript, instead of applying Typescript to their codebase. That last one is a bit tongue-in-cheek; but to some extend Typescript does force you to do more work (even if just a little), on top of regular Javascript. But let’s dive in and take […]

3 reasons to use classes over constructor functions in Typescript

Have you ever spent any time working in Typescript (or Javascript, really), and found yourself wondering if you should use constructor functions – which is commonplace in Javascript – or use Classes? Well, look no further! In this article we’ll be going over just three reasons for using classes instead of constructor functions when building […]

Why ‘optional’ is powerful in Typescript

Coming from another language, feeling like the optional type is pointless? Like many others, perhaps you have also noticed that it is indeed possible to define a class or even an interface with a sub-interface. This prevents you from creating the object without defining all the properties, they’re not even nullable and that’s great! Let’s […]

Arguments for why a team should use Typescript instead of Python

Typescript is statically typed and has compile time checks, which significantly boosts developer experience. I realize that is as close to what the official docs says as it can get without me quoting it directly, but I honestly don’t think you need to say more than that! So you would use Typescript over python, for […]