export type Mutable = { -readonly [P in keyof T]: T[P]; }; export type ValueOf = T[keyof T]; export type Merge = Omit & N; /** utility type to assert that the second type is a subtype of the first type. * Returns the subtype. */ export type SubtypeOf = Subtype; export type ResolutionType any> = T extends ( ...args: any ) => Promise ? R : any; // https://github.com/krzkaczor/ts-essentials export type MarkOptional = Omit & Partial>; export type MarkRequired = Exclude & Required>; export type MarkNonNullable = { [P in K]-?: P extends K ? NonNullable : T[P]; } & { [P in keyof T]: T[P] }; export type NonOptional = Exclude; // ----------------------------------------------------------------------------- // type getter for interface's callable type // src: https://stackoverflow.com/a/58658851/927631 // ----------------------------------------------------------------------------- export type SignatureType = T extends (...args: infer R) => any ? R : never; export type CallableType any> = ( ...args: SignatureType ) => ReturnType; // --------------------------------------------------------------------------— // Type for React.forwardRef --- supply only the first generic argument T export type ForwardRef = Parameters< CallableType> >[1]; export type ExtractSetType> = T extends Set ? U : never; export type SameType = T extends U ? (U extends T ? true : false) : false; export type Assert = T;