UNPKG

typescript-type

Version:
19 lines (10 loc) 715 B
export type None<T> = { [K in keyof T]?: never }; export type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never }; export type Intersect<T, U> = { [P in keyof (T | U)]: T[P] | U[P] }; export type Disjoint<T1, T2> = Extract<keyof T1, keyof T2> extends never ? T2 : never; export type XOR<T, U> = (T | U) extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U; export type Only<T, U> = { [P in keyof T]: T[P]; } & { [P in keyof U]?: never; }; export type Either<T, U> = Only<T, U> | Only<U, T>; export type EitherOrBoth<T1, T2> = T1 & None<T2> | T2 & None<T1> | T1 & T2; export type Cast<X, Y> = X extends Y ? X : Y; export type PartialRecord<K extends keyof any, T> = { [P in K]?: T; };