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.
infer
In this blog post, we explore how we can extract parts of composite 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 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.
satisfies
operatorTypeScript’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.
In this blog post, we look at how can make things “read-only” in TypeScript – mainly via the keyword readonly
.
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:
JavaScript’s Arrays are so flexible that TypeScript provides two different kinds of types for handling them:
Array<string>
[number, string, boolean]
In this blog post, we look at the latter – especially how to compute with tuples at the type level.
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:
The ECMAScript proposal “RegExp escaping” (by Jordan Harband and Kevin Gibbons) specifies a function RegExp.escape()
that, given a string text
, creates an escaped version that matches text
– if interpreted as a regular expression.
This proposal is currently at stage 3.
In this blog post, we take a closer look at TypeScript enums:
The blog post concludes with recommendations for what to use when.