You can make use of the Readonly<Type>
utility type.
interface Todo {
title: string;
}
const todo: Readonly<Todo> = {
title: "Delete inactive users",
};
todo.title = "Hello";
When trying to modify todo
in the last line, a typ error occurs:
Cannot assign to 'title' because it is a read-only property.