ğ TypeScript Fundamentals series : interfaces, type aliases, unions, tuples Part 2: Writing Safer Code: inference, strict mode, unknown, narrowing Part 3: Reusable Types: generics, utility types, enums vs literal unions (you are here) Each part stands on its own. Read them in order, or jump straight to the one you need. As your codebase grows you'll find yourself writing the same type over and over with small variations: a list of users, a list of orders, a "user but with every field optional".
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Articles by Grant Riordan
How to Query Data in DynamoDB Using .Net
If you're coming to DynamoDB from a relational background, the first thing to understand is this: it's a completely different way of thinking. DynamoDB isn't a relational database, it's a NoSQL key-value and document store. You don't write arbitrary queries against your data. Instead, you design your tables around the specific access patterns your application needs. DynamoDB is driven by your queries, not your data. There's no need for joins or heavy normalisation.
Stop Writing Raw Python - Let C Handle It
April 2026 · 6 min read* A .NET developer's guide to Python performance — and why the rules are different I've spent most of my career in .NET. C#, the CLR, JIT compilation — these are things I know deeply. I'm proficient in TypeScript and JavaScript for full-stack and mobile work. Python, though, has always been at arm's length. I never really needed to cross over into that world. That changed recently.
Why Python Told Me To Stop Writing My Own Code
April 2026 · 6 min read* A .NET developer's guide to Python performance — and why the rules are different I've spent most of my career in .NET. C#, the CLR, JIT compilation — these are things I know deeply. I'm proficient in TypeScript and JavaScript for full-stack and mobile work. Python, though, has always been at arm's length. I never really needed to delve into that very popular ecosystem. That changed recently.
AI Can Not Be Left Unsupervised
"AI is dangerous" — is a phrase you may hear a lot, and I have to agree. But, the most dangerous words in tech right now aren't "AI is dangerous", they're "it'll probably be fine". In a society where the use of AI has become the norm, people have become almost complacent around the dangers of it. This week I read an article on Dev.to here, telling a story where an employee had "trusted AI to organize my backlog." Two hours later, they returned to a development team's worst nightmare.
How to Work With Dapper in .Net
When you're working with .NET, interacting with databases (particularly SQL databases) is inevitable. Common approaches involve using ORM (Object Relational Mapping) with tools like Entity Framework. Dapper stands out as a lightweight and high-performance ORM tool with numerous advantages. But where Dapper really excels is in its speed and control. Here, we'll explore Dapper's suitability for performance-critical .NET projects with simpler database relationships utilising raw SQL queries.
How to Implement Type Safe Unions in C# With OneOf
Have you ever needed a method to return different types depending on the situation? Perhaps a payment processor that returns different payment types, an order that can be in various states with different data, or better, a file loader that handles multiple formats? In C#, we typically solve this with inheritance hierarchies, marker interfaces, or wrapper objects – all of which add complexity and reduce type safety. But luckily, there's a better way: discriminated unions using the OneOf library.
Spread Operator and Chaining in JS/TS
Hey, so I’m sometimes asked how the spread operator works in JS especially when working with chained statements. Some confuse the ... (spread) operator as applying to the first element of the chain, spreading the variable before applying chained functions. This isn’t correct; it applies to the result of the chain.
LeetCode 8: String to Integer (atoi) - Medium
Mastering LeetCode 8: String to Integer (atoi) A Simple and Efficient Solution LeetCode's String to Integer (atoi) is a classic medium-difficulty coding problem that challenges you to convert a string representation of a number into an actual integer. While it sounds straightforward, the problem comes with a few twists: you need to handle leading whitespace, account for positive or negative signs, and ensure the result stays within the 32-bit signed integer range.
How to Use Loops in C#
Writing the same code repeatedly is poor practice in C# and doesn’t follow the Don’t Repeat Yourself (DRY) principle. But, there are many times in programming where you need to repeat commands, operations, or computations multiple times — perhaps changing one small thing each iteration. This is where loops come in.
Extension Members: My New Favourite Feature in C# 14
The release candidate of .Net10 was released on the 9th September [2025], which comes with C# 14, and with that comes one of my favourite features, Extension Members The Concept The new extension keyword defines an extension scope; a block where you declare which type your extension methods apply to. All methods inside that scope automatically extend the specified type.
LeetCode 168: Excel Sheet Column Title (Easy)
This problem is essentially a base-26 conversion, where the "digits" are the 26 letters of the alphabet (A–Z). Like any base conversion, we process the least significant digit first — meaning we figure out the last letter of the result before the first. Use the modulo operator (% 26) to find the remainder, which tells us the current character. Insert each character at the front of the string (or reverse later), since we’re building the result from right → left.
Stop Throwing Exceptions: The ServiceResult Pattern for Clean API
Error handling in APIs can get pretty messy, right? Whether it's throwing exceptions for "expected" situations like “User not found,” or dealing with ambiguous null values, traditional error handling approaches often leave us with more questions than answers. But don't worry—there's a better way! Imagine you're a waiter taking orders: if a customer orders a dish that’s not available, you don’t throw a tantrum or drop everything in the kitchen (throw Exception).
How to Build Micro Frontends in React with Vite and Module Federation
Micro Frontend Architecture has become increasingly popular in recent years, as teams look to re-use parts of their existing applications in new projects rather than rebuilding everything from scratch. Micro frontends also allow large teams to share common components – such as headers, footers, and logins – across multiple applications, ensuring consistency and keeping their projects DRY (Don’t Repeat Yourself).
C# LeetCode 104: Maximum Depth of Binary Tree - (Easy)
Problem Given the root of a binary tree, return its maximum depth. A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Approach The function MaxDepth is recursive, meaning it calls itself to break the problem into smaller subproblems. If the current node is null (we’ve gone past a leaf), the depth is 0.
Problem Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The order of the elements may be changed. Then return the number of elements in nums which are not equal to val. Consider the number of elements in nums which are not equal to val be k, to get accepted, you need to do the following things: Change the array nums such that the first k elements of nums contain the elements which are not equal to val.
C# LeetCode 69: Sqrt(x)
Problem Given a non-negative integer x, return the square root of x rounded down to the nearest integer. The returned integer should be non-negative as well. You must not use any built-in exponent function or operator. For example, do not use pow(x, 0.5) in c++ or x ** 0.5 in python. Example 1: Input: x = 4 Output: 2 Explanation: The square root of 4 is 2, so we return 2.
Python LeetCode 70: Climbing Stairs - (Easy)
Problem You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Example 1: Input: n = 2 Output: 2 Explanation: There are two ways to climb to the top. 1 step + 1 step 2 steps Code def climbStairs(self, n: int) -> int: # if less than or equal to 2 steps, we know there's 1 way or 2 ways.
LeetCode 1: Two Sum (C#)
LeetCode 1: Two Sum Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.
Coding The Fibonacci Sequence In Python
The Fibonacci sequence is a series of numbers where each number is the sum of the previous two: 0, 1, 1, 2, 3, 5, 8, 13, ... Enter fullscreen mode Exit fullscreen mode Itβs one of the most famous sequences in math and programming β and it turns up a lot! What triggered me to write this quick blog was a fun example of the Fibonacci algorithm being used on LeetCode's Climbing Stairs problem. πͺ The Climbing Stairs Story Imagine a staircase with n steps.
Understanding O(n) vs O(1) Space Complexity in Programming
When developing, you may have heard terms like linear space O(n) and constant space O(1), or seen them completing coding challenges; but what do they actually mean? These terms describe the space requirements of an algorithm and how those requirements grow as the input size increases. They're part of what's known as Big O notation, a mathematical way to describe algorithmic efficiency — both in terms of time and space. This post focuses on space complexity. What Is Space Complexity?
What Are JSON Web Tokens (JWT)?
When you’re working with any website, application, or API, you'll inevitably need to log in and authenticate your user base. One of the more commonly used methods of passing around authentication credentials from one system to another is using a JSON Web Token (JWT). In this article, you'll learn about: What a JSON Web Token (JWT) is How JWTs are structured and created Different JWT signing techniques and algorithms (Symmetric vs.
How to Create Accessible and User-Friendly Forms in React
When designing web applications, you’ll often be asked the age old question “How accessible is your website” and “Does it offer the best user experience?”. These are both very valid questions, but they are often overlooked in favour of rich or fancy looking features, reducing the site’s audience.
How to Use Collections in C# - Lists, Arrays, Dictionaries, and More
One of the first challenges beginners face when developing applications in C# is organising and managing data efficiently. Imagine keeping track of a list of items, mapping unique keys to values, or ensuring there are no duplicates in a collection – these are all common tasks where choosing the right data structure can make a big difference. C# provides a rich set of built-in data structures, such as lists, dictionaries, and more, making it easier to work with data differently.
Day 13: Claw Contraption (Maths, Maths, and more Maths). Link to Solution Today's Challenge was done in Python for a change. This choice was made to: a) test my python / learn more python b) it looked like a very heavy mathematical puzzle today, so felt Python would be perfect, and I was NOT wrong - it was lightning fast.
Advent of Code '24 - Day 10: Hoof It
Advent of Code Day 10: Hoof It Link to Solution This one (like many other it seems) managed to inadvertently solve Part 2 whilst doing Part 1, or at least Part 2 required very little extra effort. Summary of Problem & Solution I think where many of us devs went wrong today as we didn't fully understand the requirement of : A trailhead's score is the number of 9-height positions reachable from that trailhead via a hiking trail.
Advent of Code '24 - Day9: Disk Fragmenter (Python)
Advent of Code Day 9: Disk Fragmenter Today's solution was only done in Python today, as tbh, i'm finding it hard to find the time to write in both Python and C# as well as a write-up, so opting to do one of the other going forward.
AoC '24 Day 8: Resonant Collinearity
Day 8: Resonant Collinearity This one was a lot tougher than it needed to be because the instructions were so poor (common problem people have found on the forums). You can find my solution at repo Concept of solution: In Part 1, the goal is to find pairs of antennas (points), draw a line between them, and place antinodes 1 step away from each antenna along the line.
AoC '24 - Day7: Bridge Repair
Day 7: Bridge Repair For this solution, I found the best way was using recursion. Recursion is when a function calls itself to solve smaller parts of a problem. It's like solving a big puzzle by breaking it into smaller, identical puzzles. Each time the function calls itself, it works on a smaller piece of the original problem. Recursion has two main parts: Base Case: This is when the recursion stops. It's the simplest possible version of the problem.
AoC '24 - Day 6: Guard Gallivant
Part 1, I traverse the grid until hitting an obstacle, where I update the currentRow and column implementing the rule of "always turn right". Using a HashSet we're able to store the unique visited nodes, and then simply count them. Part 2: As in Part 1, we simulate the path of the Guard, however this time round we're also checking for loops. To detect if the guard enters a loop, a visited set HashSet<(int, int, int, int)> keeps track of the guard's position and its current movement direction.
AoC 24 - Day 5: Print Queue (C#)
Today's challenge was validating a custom sort order based on a pre-defined set of rules. Summary of Solution We were asked to validate an update (array of integers) was in the correct order, based on on a set of rules defined in the puzzle’s input. The first thing I thought, was to store these rules in a constant Dictionary, as we don’t care about the order of the “subordinate” pages (pages in which the defined page must be before), just that the given number is before them.
How to Simplify Your Git Commands with Git Aliases
As a developer, you probably use the Git CLI (Command Line Interface) daily. However, writing the same old commands repeatedly can be laborious, especially when the commands are lengthy. This is where Git aliases come in to help out. In this article, you’ll learn how to simplify your Git commands by using aliases. Prerequisites Summary Knowledge of Git. Git Bash installed (optional but recommended Windows users). An IDE like VS Code (this is also optional).
How to Write Extension Methods in C#
Extension methods are a fundamental part of C# and Object Oriented Programming (OOP). Extension methods in C# allow you to "extend" existing types, including classes, interfaces, or structs, without modifying their original code. This is particularly useful when you want to add new functionality to a type you don't own or can't change, like types from third-party libraries or built-in .NET types such as string, List<T>, and so on.
How to Create a Reusable Modal Component in React
When using React, we strive to create reusable components as much as we can to limit the number of components and repetition. This keeps your code “DRY”. DRY is a concept you may have come across—it means “Don’t Repeat Yourself”. DRY is a coding principle that encourages you to minimize code duplication by using abstractions like functions or modules. It's important because it reduces redundancy, makes code easier to maintain, improves readability, and decreases the risk of errors during updates.
Code Comments Are Not Evil
Code should be self-documenting, there’s no need for comments. As a developer, you’ll have heard someone in your team say this phrase at one point if not many. It’s a common ideology many repeat, often because they think it’s the right viewpoint to have as a developer and not necessarily what they believe in themselves. What’s My Opinion? I feel that comments have a time and a place, especially with different programming languages. Don't overuse comments.
Show More
loading
Actions
Is this you?
As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.Get in touch with Grant
Contact Grant, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack