Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

Make Object properties Readonly TypeScript

//Readonly
type MyReadonly<T> = {
	readonly [K in keyof T]: T[K];
};
interface TodoRead {
	title: string;
	description: string;
}

const todoRead: MyReadonly<TodoRead> = {
	title: 'Hey',
	description: 'foobar',
};
 
PREVIOUS NEXT
Tagged: #Make #Object #properties #Readonly #TypeScript
ADD COMMENT
Topic
Name
3+3 =