2025-02

Demo: running TypeScript directly in Node.js

[2025-02-20] dev, typescript

I have published the repository nodejs-type-stripping which demonstrates how to implement a package with a bin script that is written directly in TypeScript (no transpilation).

The bottom type never in TypeScript

[2025-02-19] dev, typescript

In this blog post, we look at the special TypeScript type never which, roughly, is the type of things that never happen. As we’ll see, it has a surprising number of applications.

Array type notations: T[] vs. Array<T> in TypeScript

[2025-02-17] dev, typescript

In this blog post, we explore two equivalent notations for Arrays in TypeScript: T[] and Array<T>. I prefer the latter and will explain why.

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

In TypeScript, conditional types let us make decisions (think if-then-else expressions) – which is especially useful in generic types. They are also an essential tool for working with union types because they let use “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 operator.

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.