TypeScript · Middle · Question 56 of 75

Why might Readonly<Settings> not prevent this change?

const s: Readonly<Settings> = load();
s.theme.colors.primary = 'red';

Explanation

A recursive DeepReadonly type or as const for literals protect nested levels at the type level.

Further reading

Problem with a question

TypeScript · Middle · question 56

Test yourself

Take the TypeScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz