Readonly
Constructs a type with all properties of Type set to readonly, meaning the properties of the constructed type cannot be reassigned.
Example
interface Todo {
title: string;
}
const todo: Readonly<Todo> = {
title: "Delete inactive users",
};
todo.title = "Hello";
Cannot assign to 'title' because it is a read-only property.
Released:
2.1
Refencence: Typescript offical documentation
Top comments (0)