Generation

generate functionFri, 13 Jan 2023

create an interface object that extends data with readonly attributes

type Readonly<T> = { readonly [P in keyof T]: T[P]; } interface Point { x: number; y: number; } const p1: Readonly<Point> = { x: 10, y: 20, }; p1.x = 5; // error!

TypeScript
Generate More

Questions about programming?Chat with your personal AI assistant