TypeScript · Senior · Question 73 of 75

What does Object.freeze return in terms of types?

const config = Object.freeze({ mode: 'dark', retries: 3 });

Explanation

Nested objects are neither frozen at runtime nor readonly in the type. as const makes all levels readonly at the type level only.

Further reading

Problem with a question

TypeScript · Senior · question 73

Test yourself

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

Take this quiz