Deep Readonly Utility in typescript

preview_player
Показать описание
TypeScript has a Readonly utility type that can make all properties of a type read-only. But there’s a catch: it’s not deep. This means if we have nested objects, the nested properties are not read-only. Let’s see an example.
Here, obj.a = 2 will give an error because a is read-only. But obj.b.c = 'World' does not give an error as Readonly is not deep. This is where our Deep Readonly utility will come in handy.
Рекомендации по теме