/** * Make all properties and nested properties of an object readonly. This type * is similar to `Readonly` but it also makes nested properties readonly. * * @template T The type to make readonly. * @example ReadonlyDeep<{ a: { b: string } }> = { readonly a: { readonly b: string } } */ type Immutable = { readonly [P in keyof T]: T[P] extends Record ? Immutable : T[P] extends any[] ? Immutable : T[P]; }; export type { Immutable };