// eslint-disable-next-line @typescript-eslint/no-empty-object-type export type Simplify = { [K in keyof T]: T[K] } & {} export type RequiredKey = Simplify< T & { [L in K]-?: unknown extends T[L] ? NonNullable | null : Exclude } > export function either( a?: T, b?: T, ): T | undefined { if (a != null && b != null && a !== b) { throw new TypeError(`Expected "${b}", got "${a}"`) } return a ?? b ?? undefined }