Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumTypeScripthand-rolled utility typesSingle-choice MCQ

What prevents this hand-rolled `DeepReadonly` from also making array/function members readonly correctly, and what does the assignment do?

type DeepReadonly<T> = { readonly [K in keyof T]: T[K] extends object ? DeepReadonly<T[K]> : T[K]; }; type X = DeepReadonly<{ a: { b: number } }>; const x: X = { a: { b: 1 } }; x.a.b = 2;