UNPKG

@wireapp/commons

Version:

Collection of common components that are used across Wire web applications.

31 lines 1.04 kB
export type FalsyType = false | null | undefined | '' | 0; /** * Makes all properties of a type recursively optional * @see https://stackoverflow.com/a/51365037 * @since TypeScript 2.8 */ export type RecursivePartial<T> = { [P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P]; }; /** * Retreive all optional keys from an interface * @see https://stackoverflow.com/a/52991061 */ export type OptionalKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? K : never; }[keyof T]; /** * Retreive all required keys from an interface * @see https://stackoverflow.com/a/52991061 */ export type RequiredKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? never : K; }[keyof T]; export type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never; }; /** * Only allows one type or the other, but not a mix of types */ export type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U; //# sourceMappingURL=TypeUtil.d.ts.map