JavaScript React

Functional React components with generic props in TypeScript

One of the qualities of our code that we should aim for is reusability. Also, following the Don’t Repeat Yourself principle makes our code more elegant. In this article, we explore writing functional React components with TypeScript using generic props. By doing so, we can create reusable and flexible components. If you would like to […]

JavaScript TypeScript Uncategorized

More advanced types with TypeScript generics

Previously, we’ve discussed the basics of TypeScript Generics. This time, we take them to a higher level. In this article, we learn about index types. To do so, we also explore union types, the keyof keyword, and string literal types. Today we also learn mapped types and use them with conditional types. Index types Generics are very useful in many situations. […]

Uncategorized

TypeScript Generics. Discussing naming conventions

We can find the concept of generic types across many languages such as Java, C#. Naturally, they found their way into TypeScript. In this article, we discuss their purpose and provide various examples. We also discuss naming conventions for generics that we can stumble upon. Introducing TypeScript Generics One of the qualities that we strive […]

Express JavaScript TypeScript

TypeScript Express tutorial #13. Using Mongoose virtuals to populate documents

This entry is part 13 of 15 in the TypeScript Express tutorial

Throughout this series, we’ve created some schemas and models for documents. We’ve also established ways to define relationships between them. We sometimes find ourselves needing many different properties in our documents. They sometimes overlap each other, and we might want to avoid duplicating the data in the database. Also, we might want to avoid two-way […]

JavaScript TypeScript

Applying SOLID principles to your TypeScript code

The SOLID principles were defined quite some time ago and are still relatable. Their goal is to make our software easier to understand, read, and extend. We accredit this concept to Robert C. Martin from his paper from the year 2000. The actual SOLID acronym was defined later, though. In this article, we go through all […]