TSC Watch

Today I’m doing course that uses TypeScript files, but I don’t have my tooling like ALE, ESLint, and Prettier because they’re inside a highly configured project directory. I’ve got a workaround: watching the file with my compiler. ...

December 29, 2025

Why I'm "All In" on TypeScript

I’ve added TypeScript to several projects I’ve worked on. In this post, I’d like to discuss why I think TypeScript is essential and document my expectations around it. ...

March 26, 2025

Either/Or Props in TypeScript

Sometimes in TypeScript we’d like to say a function can either have one typed prop, or the other, never both and never neither. This can be achieved with a union type and type never: type Props = { markdown: string, copy?: never } | { markdown?: never, copy: string} }; const component = ({ markdown, copy }: Props) => markdown ? parseMarkdown(markdown) : <>copy</>; console.log(component({ markdown: "### Important" })) // <h3>Important</h3> console.log(component({ copy: "Just information" })) // <>Just information</> console.log(component({ copy: "Just information", markdown: "### That conflicts })) // ❌ Type error console.log(component({})) // ❌ Type error Our component can receive a string of markdown, which it will parse, or raw copy, which it will not parse. Always just one, never both, and never neither.

July 22, 2024

TypeScript Union Type From Array

With the new as const construct, we can derive a TypeScript union type from a JavaScript array! const builderSteps = [ 'communications', 'estimates', 'health status', 'procedures' ] as const; type BuilderStep = (typeof builderSteps)[number]; This lets us both type a slice of state, type its updater, and build JSX elements all from the same array, a virtuous cycle. const [step, setStep] = useState<BuilderStep>('communications') const handleStepClick = (step: BuilderStep) => setStep(step) {builderSteps.map(step => <button key={step} onClick={() => handleStepClick(step)}>{step}</button>)} const assertions

December 11, 2023

Absolute Imports in TypeScript and React: A Practical Guide

Absolute imports are an essential developer experience feature for me in any JavaScript application. In this post, I’ll explain what they are, how to use them, and why they matter. ...

May 2, 2023

Type Your TypeScript Library Functions

There’s been a lot of recent discussion in the TypeScript community about typing functions. These arguments tend to take binary positions: always type your functions, or never type them unless the compiler demands it. Which is the best option? ...

March 1, 2023

Solving Exercism's Resistor Color Trio in TypeScript

Today I completed the ‘Resistor Color Trio’ TypeScript exercise on Exercism. Here’s my solution. ...

October 26, 2022

Solving Exercism's Resistor Color Duo in TypeScript

Today as a code kata I completed the ‘Resistor Color Duo’ TypeScript exercise on Exercism. Here’s my work. ...

October 24, 2022

Pangram in TypeScript

I’ve been doing Exercism’s TypeScript exercises, and wanted to share my pangram-checking utility. ...

July 29, 2019

Don’t miss my next essay

Hear from me immediately when I post: no ads, unsubscribe anytime.