2025-02

Symbols in TypeScript

[2025-02-17] dev, typescript

In this blog post, we examine how TypeScript handles JavaScript symbols at the type level.

If you want to refresh your knowledge of JavaScript symbols, you can check out chapter “Symbols” of “Exploring JavaScript”.

Conditional types in TypeScript

[2025-02-15] dev, typescript

A conditional type in TypeScript is an if-then-else expression: Its result is either one of two branches – which one depends on a condition. That is especially useful in generic types. Conditional types are also an essential tool for working with union types because they let us “loop” over them. Read on if you want to know how all of that works.

Mapped types in TypeScript

[2025-02-14] dev, typescript

A mapped type is a loop over keys that produces an object or tuple type and looks as follows:

{[PropKey in PropKeyUnion]: PropValue}

In this blog post, we examine how mapped types work and see examples of using them. Their most importing use cases are transforming objects and mapping tuples.

TypeScript: extracting parts of compound types via infer

[2025-02-10] dev, typescript

In this blog post, we explore how we can extract parts of compound types via the infer keyword.

It helps if you are loosely familiar with conditional types. You can check out section “Conditional types” in “Tackling TypeScript” to read up on them.

TypeDoc: testing code examples in doc comments

[2025-02-09] dev, typescript

TypeDoc now lets us refer to parts of other files via {@includeCode}. In this blog post, I explain how that works and why it’s useful.

TypeScript: the satisfies operator

[2025-02-08] dev, typescript

TypeScript’s satisfies operator lets us check the type of a value (mostly) without influencing it. In this blog post, we examine how exactly it works and where it’s useful.

Read-only accessibility in TypeScript

[2025-02-06] dev, typescript

In this blog post, we look at how can make things “read-only” in TypeScript – mainly via the keyword readonly.

Tutorial: publishing ESM-based npm packages with TypeScript

[2025-02-04] dev, typescript

During the last two years, ESM support in TypeScript, Node.js and browsers has made a lot of progress. In this blog post, I explain my modern setup that is relatively simple – compared to what we had to do in the past:

2025-01

Computing with tuple types in TypeScript

[2025-01-29] dev, typescript

JavaScript’s Arrays are so flexible that TypeScript provides two different kinds of types for handling them:

  • Array types for arbitrary-length sequences of values that all have the same type – e.g.: Array<string>
  • Tuple types for fixed-length sequences of values where each one may have a different type – e.g.: [number, string, boolean]

In this blog post, we look at the latter – especially how to compute with tuples at the type level.

Template literal types in TypeScript: parsing during type checking and more

[2025-01-24] dev, typescript

In this blog post, we take a closer look at template literal types in TypeScript: While their syntax is similar to JavaScript’s template literals, they operate at the type level. Their use cases include:

  • Static syntax checking for string literals
  • Transforming the casing of property names (e.g. from hyphen case to camel case)
  • Concisely specifying large string literal union types