/** * A TypeScript utility type that enforces only one or none specified properties of a given type to be present. */ export type AtMostOne = { [K in Keys]: { [P in K]: T[K]; } & Partial, never>>; }[Keys]; /** * A TypeScript utility type that enforces exactly one specified property of a given type to be present. */ export type ExactlyOne = { [K in Keys]: { [P in K]-?: T[P]; } & { [P in Exclude]?: never; } & Omit; }[Keys];