TypeScript

Deep readonly & immutability

Në shqip: Pandryshueshmëria e thellë

ShpjegimiSQ

Readonly<T> mbron vetëm nivelin e parë. Për objekte të ndërthurura, shkruan një DeepReadonly<T> rekursiv ose përdor as const, që asgjë brenda të mos ndryshohet aksidentalisht.

EnglishEN

Readonly<T> protects only the first level. For nested objects, write a recursive DeepReadonly<T> or use as const, so nothing inside gets changed by accident.

Si ta mendosh

Si ta mbyllësh me xham jo vetëm kutinë, por edhe çdo sirtar brenda saj.

Lexoje në anglisht

Like glassing in not just the cabinet, but every drawer inside it.

Shembull koditypescript

type DeepReadonly<T> = { readonly [K in keyof T]: DeepReadonly<T[K]> };

Terma të lidhur