Sequence NODE_163
EasyCreate a Readonly User Type
TypeScript
Technical Specification
Create a ReadonlyUser type in which all properties from User are readonly.
Input/Output Samples
Input:Try reassigning user.id
Output:Type error
Optimal Logic Path
type User = {
id: number;
name: string;
email: string;
isAdmin: boolean;
};
type ReadonlyUser = Readonly<User>;Architectural Deep-Dive
Readonly<T> creates a new type where all properties of T cannot be reassigned.