The Partial keyword in Typescript has many uses, but when is actually a good use case for using it? Well I’ve got a few quick ones so let’s dive in! Extending types to reduce maintenance Familiar with the DTO pattern? No? If not, this section is definitely for you! Popularized by Java – at least […]
What’s a good use case for using Partial
Why ‘satisfies’ is a BIG deal
With the most recent Typescript version as of today – 4.9 – among a bunch of features (that I’ll make sure to cover in other posts) we are getting access to the satisfies keyword and that is a big deal! Bigger than you think, at least. At its core level the purpose of the satisfies […]
I used to hate Typescript. Here’s why I love it now
While Typescript has a high rate of adoption and it is generally very well-regarded in the community, there are still many developers that – despite Typescripts many advantages – still prefer Javascript. I myself had a preference for Javascript well into 2021, before I finally succumbed to the allures of Typescript, and decided to give […]
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 […]
How to get better at Typescript Generics
Generics are hard! Or at least, many of us seem to think that way. It is a viewpoint I have seen shared many times over, partially implying that “Generics” is a concept, much more difficult than most other Typescript concepts. I’m here to tell you, it’s not! It’s easy for that all-too-common imposter syndrome to […]
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 […]