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.
Casts a mutable type
T
to itsReadonly<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.