devtypes - v2.0.0
    Preparing search index...

    Type Alias DeepReadonly<T>

    DeepReadonly: T extends Function
    | Date
        ? T
        : T extends (infer U)[]
            ? ReadonlyArray<DeepReadonly<U>>
            : T extends ReadonlyArray<infer U>
                ? ReadonlyArray<DeepReadonly<U>>
                : T extends Map<infer K, infer V>
                    ? ReadonlyMap<K, DeepReadonly<V>>
                    : T extends ReadonlyMap<infer K, infer V>
                        ? ReadonlyMap<K, DeepReadonly<V>>
                        : T extends Set<infer U>
                            ? ReadonlySet<DeepReadonly<U>>
                            : T extends ReadonlySet<infer U>
                                ? ReadonlySet<DeepReadonly<U>>
                                : T extends PlainObject
                                    ? { readonly [K in keyof T]: DeepReadonly<(...)[(...)]> }
                                    : T

    Recursively make all properties readonly.

    Type Parameters

    • T

      Object type to transform

    Applies readonly modifiers deeply at all nesting levels.

    Function types and special types like Date are preserved unchanged.

    type User = { id: number; profile: { name: string; address: { city: string } } };
    type Readonly = DeepReadonly< User >;
    // { readonly id: number; readonly profile: {
    // readonly name: string; readonly address: { readonly city: string }
    // } }