export declare class UnreachableError extends Error { /** @param x an unreachable value */ constructor(x: never); } export declare type PartialBy = Omit & Partial>; export declare type RequiredBy = Omit & { [F in K]-?: Exclude; }; /** * Convert a map type { [key]: value } into an map of key/value types. * For example, `{ A: 'B' }` becomes `{ A: { key: 'A', value: 'B' } }`. */ declare type KeyValuePairs> = { [K in keyof T]: { key: K; value: T[K]; }; }[keyof T]; /** * Inverts a type map. * For example, `{ foo: 'bar' }` becomes `{ bar: 'foo'}`. */ export declare type Invert> = { [K in KeyValuePairs['value']]: Extract, { value: K; }>['key']; }; /** * Replace the types of keys in T with matching type in the LookUp record. * * @example * * type Foo = { A: 'B' }; * type LookUp = { 'B': number }; * const foo: MatchKeyType = { A: 123 }; */ declare type MatchKeyType, LookUp extends Record> = { [K in KeyValuePairs['key']]: LookUp[Extract, { key: K; }>['value']]; }; /** * Create an new type from a type and a key map. * Where C, is a key name map between the source datatype T and the new type. * O represents a key value map of overrides to be applied to the new type * where the type of T is not the desire type. * * @example * * const keyNameMap = { * value: 'new_value', * name: 'new_name', * } as const; * type DataType = { * value: number, * name: string, * }; * type NewDataType = MapDataType; * * const foo: NewDataType = { * new_value: 1, * new_name: 2, * }; */ export declare type MapDataType, T extends Record, O extends Partial, any>> = {}> = Omit, T>, keyof O> & O; export {};