Typescript - MappedTypes
Mapped types are a feature in TypeScript which allow you to map over a union of types to create a new type
Using the keyof operator with mapped types gives you a smooth API to create object types from other object types
interface Person {
name: string;
age: number;
}
type NullablePerson = {
[P in keyof Person]: Person[P] | null;
};
// It equals
type NullablePerson = {
name: string | null;
age: number | null;
};