typescript: Save you Kind Widening of Object Literals with TypeScript’s const Assertions

@Andrew: Now not rather. TypeScript’s readonly modifier does no longer have any runtime manifestation — it is utterly compiled away, so ORIGIN may have two mutable homes x and y.

Object.freeze(), alternatively, freezes an object at runtime. When an object is frozen, it might probably now not be adjustments. Fro instance, belongings values cannot be modified, and homes cannot be got rid of, added, or reconfigured.

So readonly offers you some coverage thru type-checking at compile-time, while Object.freeze() in fact prevents changes at runtime.