Nullish Short-Circuit Assignment in TypeScript 4.0 (beta)

On June 26th 2020, TypeScript 4.0 Beta was announced. The update brings a myriad of useful changes, but one such addition is something you'll quickly get in to the habit of using every day: Nullish Short-Circuit Assignment. You've used a += b before…

How to unpack the return type of a Promise in TypeScript

While making @jpwilliams/distributed-promise I came across an interesting requirement: I needed to acquire the return type of an async function after it had been resolved. I needed to unwrap a promise. For example, an async function that simply…

🔗
🔗

Using EventEmitters to resolve Promises from afar in Node.js

A common-but-powerful pattern I've come to frequent is the utilisation of EventEmitter alongside a Promise, enabling me to resolve said promise from an entirely different part of my code base. To demonstrate, let's revisit the basics of both an…

Modularising GraphQL for scale

When fiddling around with GraphQL projects, I've frequently found it difficult to know where things should go. Just like naming variables, naming and placing files is hard. The simplest method here is to bundle everything in to one file, but that…

🔗
🔗

It's all about trade-offs

I recently had a great discussion regarding WebSockets and HTTP/2 with a former colleague. During the discourse, they uttered one line so deeply-set in truth that it must be shared. Repeatedly. "It's all about trade-offs." As someone who has been…