This content originally appeared on DEV Community and was authored by es404020
Readonly
Constructs a type with all properties of Type set to readonly, meaning the properties of the constructed type cannot be reassigned.
interface Todo {
title: string;
}
const todo: Readonly<Todo> = {
title: "Delete inactive users",
};
todo.title = "Hello";
Assigning a title to Todo Interface would throw an error .
Released:2.1
Reference: Official typescript docs
This content originally appeared on DEV Community and was authored by es404020

es404020 | Sciencx (2021-09-08T07:17:16+00:00) Typescript Utility Readonly. Retrieved from https://www.scien.cx/2021/09/08/typescript-utility-readonly/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.