• 8th March 2024

Nix, NPM, and Dependabot

I have a project, git-format-staged, that I build with Nix. It includes NPM dependencies, and it is convenient to have Dependabot keep those up-to-date for me. Dependabot creates pull requests that update package-lock.json when it sees updates with security fixes and such. But my Nix configuration includes a hash of the project NPM dependencies - that hash must be updated when package-lock.json changes. Unfortunately Dependabot does not know how to do that. So I came up with a workflow to help that bot out. …

Read more 
  • 4th December 2021

`void` is not a unit type in TypeScript

In type theory a unit type is any type that represents exactly one possible value. The unit types in TypeScript include null, undefined, and literal types. TypeScript also has the type void which is used as the return type for functions that don’t have an explicit return value. In JavaScript a function that does not explicitly return implicitly returns undefined; so at first glance it would seem that void is an alias for the undefined type. But it is not! …

Read more 
  • 29th April 2020

Choosing a headless CMS

A headless CMS does not come with a web interface where readers will see published content. Instead, a headless system acts more like a database: it hosts content, and your app uses an API to fetch content to display. As a result, your choice of app architecture is not tied to your choice of CMS. This can be especially helpful if you want to incorporate managed content into an app that is not primarily a publishing platform, or if you want to present the same content differently in different contexts as was the case with our web vs mobile apps.

Read more 
  • 29th January 2019

When to use `never` and `unknown` in TypeScript

This is an excerpt of a post that I wrote for LogRocket. The never and unknown primitive types were introduced in TypeScript v2.0 and v3.0 respectively. These two types represent fundamental and complementary aspects of type theory. TypeScript is carefully designed according to principles of type theory, but it is also a practical language, and its features all have practical uses – including never and unknown. To understand those uses we will have to begin with the question, what exactly are types? …

Read more 
  • 12th April 2018

Checking Types Against the Real World in TypeScript

Learn how to use io-ts validators to ensure that incoming data is compatible with your program contracts.

Read more 
  • 12th February 2018

Type-Driven Development with TypeScript

This is an excerpt of a post that I wrote for Olio Apps. I am always interested in making my coding process faster and more robust. I want to be confident that my code will work as expected. And I want to spend as little time as possible debugging, testing, and hunting down pieces of code that I forgot to update when I make changes to a project. That is why I am a fan of correct-by-construction methods. Those are methods of constructing programs where the program will not build / compile unless it behaves the way that it is supposed to. …

Read more