Readonly easy #built-in #readonly #object-keys

by Anthony Fu @antfu

Take the Challenge    简体中文 日本語 한국어 Português (BR)

Implement the built-in `Readonly` generic without using it. Constructs a type with all properties of T set to readonly, meaning the properties of the constructed type cannot be reassigned. For example: ```ts interface Todo { title: string description: string } const todo: MyReadonly = { title: "Hey", description: "foobar" } todo.title = "Hello" // Error: cannot reassign a readonly property todo.description = "barFoo" // Error: cannot reassign a readonly property ```
Back Share your Solutions Check out Solutions

Related Challenges

8・Readonly 2 9・Deep Readonly