All posts in category #TypeScript

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.

Union types, pattern matching and exhaustiveness in today's JavaScript

Despite being a small library, there is a lot we can do with daggy
Pattern matching and union types are, in my view, one of the concepts in programming which don't get the attention they deserve. In this post, I'm going to show how they can help us write more declarative code.

"TS2307: Cannot find module" with custom modules-folder in yarn

Sometimes we may choose to change the default location of the node_modules folder when we work with yarn. Our build may start failing with TS2307 error but there is a workaround.