Search⌘ K
AI Features

Advanced Types and Modules

Explore advanced TypeScript types such as Partial, Record, and union types to improve flexibility in Angular applications. Understand how to organize and reuse code effectively by implementing TypeScript modules, facilitating scalable and maintainable Angular development.

Previously, we learned about some basic types in the TypeScript language that we usually meet in other high-level languages. In this lesson, we’ll look at some advanced types that will help us during Angular development.

The Partial type

The Partial type is used when we want to create an object from an interface but include some of its properties:

TypeScript 4.9.5
interface Hero {
name: string;
power: number;
}
const hero: Partial<Hero> = {
name: 'Boothstomper'
}

In the preceding snippet, we can see that the hero object does not include power in its properties ...