UNPKG

type-fns

Version:

A set of types, type checks, and type guards for simpler, safer, and easier to read code.

10 lines (9 loc) 273 B
/** * creates a type which allows specifying one, and only one, key of an object * * ref: * - https://stackoverflow.com/a/56933182/3068233 */ export type PickOne<T> = { [P in keyof T]: Record<P, T[P]> & Partial<Record<Exclude<keyof T, P>, undefined>>; }[keyof T];