Rebasely Beta: data may be purged

justintypescript-ultra-strict Public

TypeScript · 18 lines · 596 B · at 8396947

export type Profile = { name: string; email?: string; phone?: string };/** * A missing key (or `undefined`) means keep, `null` means clear, a string means set. * `name` cannot be cleared. */export type ProfilePatch = { name?: string; email?: string | null; phone?: string | null };export class ProfileError extends Error {  constructor(public readonly kind: "invalid_name" | "invalid_email" | "invalid_phone") {    super(kind);  }}/** Throws ProfileError when a value being set is invalid. */export function applyPatch(profile: Profile, patch: ProfilePatch): Profile {  // TODO}