Articles
Tuple to Object - TypeScript Challenge Explained
Mar 13, 2023
π1 min read
My solution to the Tuple to Object TypeScript Challenge as part of my journey to Understanding the TypeScript Challenges.
Given an array, transform it into an object type and the key/value must be in the provided array.
Solution
Loop over the values in ...
Readonly - TypeScript Challenge Explained
Mar 12, 2023
My solution to the Readonly TypeScript Challenge as part of my journey to Understanding the TypeScript Challenges.
Given a type T, the utility should set the readonly keyword for all properties.
Solution
Explanation
{ } return an object/record type
re...
Pick - TypeScript Challenge Explained
Mar 11, 2023
π1 min read
My solution to the Pick TypeScript Challenge as part of my journey to Understanding the TypeScript Challenges.
The MyPick generic type is a custom version of the native Pick generic function. Given a type T and a union of keys K, the generic function shou...
Uses for the TypeScript βasβ assertion
Mar 9, 2023
π1 min read
In TypeScript there is a as assertion. There are two reasons for this annotation.
Firstly it's a way to tell TypeScript that a value is of a certain type which differs from what is being inferred, or has already been set. Essentially, it's used to tell Ty...
Understanding the TypeScript Challenges
Mar 1, 2023
π1 min read
TypeScript has a robust set of built-in utility types. There are a number of ways to gain better understanding of TypeScript and recreating these utilities is one if the best ways. To guide this learning track it's a good idea to try and complete TypeScrip...
GPX doodling - a guide
Nov 2, 2022
π3 min read
Recently I drew a Halloween doodle while I was out for a run. A few people asked me how I did it, so I thought that a guide would be helpful!
There are a few steps to getting a good result:
Picking the location
Planning the doodle
Creating the doodle
...
Create a count for related items using GROQ
Oct 25, 2022
π§ Tip
I'm using the count() function of GROQ queries to display the number of posts for a tag on my tags page, but it can be used for anything that would have a varying number of items.
To count items using GROQ is as simple as using the count() function.
Of c...
Using GROQ to create an excerpt for a Sanity block
Oct 22, 2022
π3 min read
This is a quick tip on how to truncate a Sanity block field to create an excerpt using GROQ.
When querying the field using a Sanity Client and GROQ, there is no inbuilt excerpt function, or even a truncate function, so we need to do the steps ourselves.
...
Run report: To the Top of Corfu
May 26, 2022
π7 min read
πRun
A 33 km off-road trail run from the Corfiot sea side town of Roda, to the highest point on the island, Mount Pantokrator at (911 metres (2,989 ft)). A beautiful route, through olive groves, tiny villages, with views to die for, but took longer than estimat...
Fixing issues with NextJS local file APIs and Netlify functions
May 17, 2022
π2 min read
Recently I migrated my personal website to Next.js and thought I had everything working well with Netlify, however on deployment I noticed an issue with the API data...
Background
As part of my migration from Gatsby to Next.js I moved the .gpx data to a ...
Type narrowing and discriminating unions in TypeScript
May 10, 2022
π3 min read
Type narrowing is the process of moving from a less precise set of types to a more precise type or set of types. The aim of type narrowing is to reduce the types down to only the ones where the following methods or properties can be correctly accessed or c...