Type Aliases and Index Signatures

Unlock the full power of type by modeling flexible value sets and dynamic object shapes that scale with your codebase.

We’ve seen how the type keyword helps us name reusable object shapes. That was the first step—cutting down on repetition, gaining clarity, and enforcing consistency across our codebase.

But type doesn’t stop at objects.

It can describe object shapes, value sets, and even function signatures. If it has a type, we can name it. And when we need to describe objects with unpredictable keys, TypeScript has our back there, too.

Let’s level up how we write types so our code can grow without breaking.

Modeling value sets with type aliases

Let’s say we want to annotate a value that represents a user’s access level: