Code
typescript
type Readonly<T> = {
readonly [P in keyof T]: T[P];
};
type Optional<T> = {
[P in keyof T]?: T[P];
};
type Mutable<T> = {
-readonly [P in keyof T]: T[P];
};
type Nullable<T> = {
[P in keyof T]: T[P] | null;
};
interface User { id: number; name: string; }
type ReadonlyUser = Readonly<User>;
type OptionalUser = Optional<User>;