ts-data-forge
    Preparing search index...
    • Casts a mutable type T to its Readonly<T> equivalent.

      This is a safe type assertion that adds immutability constraints at the type level. The runtime value remains unchanged - only TypeScript's view of it becomes readonly. This helps prevent accidental mutations and makes code intentions clearer.

      Type Parameters

      • T

        The type of the mutable value

      Parameters

      • mutable: T

        The mutable value to cast to readonly

      Returns Readonly<T>

      The same value with readonly modifiers added to its type

      • castDeepReadonly - For deeply nested structures
      • castMutable - For the opposite operation (use with caution)