Currently diving into the chapter on objects in the TypeScript Handbook. The handbook highlights the significance of managing expectations when using the readonly properties. Here's a key excerpt:
It’s crucial to clarify what
readonly
truly signifies. It serves as a way to indicate the intended usage of an object during development with TypeScript. When comparing two types, TypeScript does not consider whether properties arereadonly
, allowing readonly properties to be altered through aliasing.
The statement "It’s important to manage expectations of what readonly implies. It’s useful to signal intent during development time for TypeScript on how an object should be used" suggests the advantages of utilizing readonly
, but I'm still trying to grasp the full depth of it.