All posts in category #Advanced

Building type utils to derive interfaces from unions of interfaces in TypeScript

Generics we're going to build to derive types from other types
In this post, we're going to build small, generic type utils in TypeScript, and we'll do that by refactoring code from real world example.

We're going to pick an approach leveraging template literals, and type inference to provide a nice developer experience.

Deriving types from other types in TypeScript — unions and interfaces

Union type to interface transition
The transition from union type to interface, and back
Maintaining a lot of similar types can be a mundane task, especially if some of them must stay in sync due to some dependency on one another.

You're going to learn how to, with a little bit of type-level programming, reduce that toil by deriving types from other types.