Make some properties optional

Typescript

Composes the built-in helpers rather than writing a second interface that will drift from the first.

type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;

type NewUser = PartialBy<User, 'id' | 'createdAt'>;

More in TypeScript

Random picks