ts-data-forge
    Preparing search index...

    Function castDeepReadonly

    • Casts a mutable type T to its DeepReadonly<T> equivalent, recursively adding readonly modifiers.

      This is a safe type assertion that adds immutability constraints at ALL levels of nesting. Provides complete protection against mutations in complex data structures. The runtime value is unchanged - only TypeScript's type checking is enhanced.

      Type Parameters

      • T

        The type of the mutable value

      Parameters

      • mutable: T

        The mutable value to cast to deeply readonly

      Returns DeepReadonly<T>

      The same value with readonly modifiers recursively added to all properties

      • castReadonly - For shallow readonly casting
      • castDeepMutable - For the opposite operation (use with extreme caution)