TSC Watch

Watch and re-transpile any TypeScript file with: tsc file.ts --watch ...

December 29, 2025 · 1 min · Jake Worth

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 · 4 min · Jake Worth

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 · 1 min · Jake Worth

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 · 1 min · Jake Worth

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 · 3 min · Jake Worth

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 · 3 min · Jake Worth

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 · 2 min · Jake Worth

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 · 2 min · Jake Worth

Pangram in TypeScript

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

July 29, 2019 · 1 min · Jake Worth

Don’t miss my next essay

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