ReadonlyPartial: { readonly [P in keyof T]?: T[P] }

Mutates the type by adding the readonly modifier and the optional modifier (?) to all properties.

Type Parameters

  • T

    The type to mutate.

type Original = { name?: string; age?: number };
type Mutated = ReadonlyPartial<Original>; // { readonly name?: string; readonly age?: number }