TypeScript · Middle · Question 56 of 75
Why might Readonly<Settings> not prevent this change?
const s: Readonly<Settings> = load();
s.theme.colors.primary = 'red';- ✓Correct answer:
Readonlyis shallow; nested objects stay mutable - 2
Readonlyworks only on arrays - 3Assignments to nested properties are always allowed in TS
Explanation
A recursive DeepReadonly type or as const for literals protect nested levels at the type level.