Built-in Mapped Types

This lesson walks through some of the built-in mapped types and explains them in detail.

We'll cover the following

Partial

Partial<T> returns a type that has the same properties as T but all of them are optional. This is most useful when the strictNullChecks flag is enabled. Partial works on a single level, meaning it doesn’t affect nested objects. A good use case for Partial is when you need to type a function that lets you override default values of properties of some object.

As you can see, Partial is defined in a similar way to Readonly. Instead of the readonly modifier, the optionality modifier ? is appended to each property of T.

Get hands-on with 1200+ tech skills courses.