import { False, True } from './conditionals'; /** * An object with string keys and values of type `any`. */ export declare type PlainObject = Record; /** * Takes any type and makes it an object type. * Useful when combined with `&` intersection types. * @param T A type who will be converted into an object * @returns An object formed by the key, value pairs of T */ export declare type ObjectType = { [k in keyof T]: T[k]; }; /** * Takes two objects and returns their intersection. * This combines all keys and uses `ObjectType` to "clean up" the resultant object. * Useful for making extremely complex types look nice in VSCode. * @param T First object to be intersected * @param U Second object to be intersected * @returns `T` & `U` cleaned up to look like flat object to VSCode */ export declare type CombineObjects = ObjectType; /** * Gets the value of specified property on any object without compile time error (`Property 'b' does not exist on type '{ a: string; }'.`) and the like. * Returns `never` if the key is not on the object. * It helps to use `If = K extends keyof T ? T[K] : never; /** * Like `GetKey`, but returns `unknown` if the key is not present on the object. * @param T Object to get values from * @param K Key to query object for value * @returns `T[K]` if the key exists, `unknown` otherwise */ export declare type TryKey = K extends keyof T ? T[K] : unknown; /** * Takes two objects and returns their element-wise intersection. * *Note*: this removes any key-level information, such as optional or readonly keys. * @param T First object to be intersected * @param U Second object to be intersected * @returns element-wise `T` & `U` cleaned up to look like flat object to VSCode */ export declare type ElementwiseIntersect = { [k in (keyof T | keyof U)]: TryKey & TryKey; }; /** * Objects can be indexed by multiple types: `string`, `number`, `symbol`. * For safe compatibility with typescript version, this type will always * have the correct set of object key types for the current version of TS. * * This is useful for functions that must take a key, instead of `K extends string`, * use `K extends ObjectKeys`. */ export declare type ObjectKeys = keyof any; /** * Typescript 2.9 introduced `number | symbol` as possible results from `keyof any`. * For backwards compatibility with objects containing only `string` keys, this will * exclude any `number | symbol` keys from `keyof`. * @param T type from which to get keys * @returns keys of `T` that extend `string` */ export declare type StringKeys = Exclude; /** * When an object has optional or readonly keys, that information is contained within the key. * When using optional/readonly keys in another object, they will retain optional/readonly status. * `PureKeys` will remove the optional/readonly status modifiers from keys. * @param T type from which to get keys * @returns keys of `T` without status modifiers (readonly/optional) */ export declare type PureKeys = Record[keyof T]; /** * Gets all of the keys that are shared between two objects. * @param T first type from which keys will be pulled * @param U second type from which keys will be pulled * @returns the keys that both `T` and `U` have in common. */ export declare type SharedKeys = keyof T & keyof U; /** * Gets all keys between two objects. * @param T first type from which keys will be pulled * @param U second type from which keys will be pulled * @returns the keys of `T` in addition to the keys of `U` */ export declare type AllKeys = keyof T | keyof U; /** * Gets all of the keys that are different between two objects. * This is a set difference between `keyof T` and `keyof U`. * Note that calling this with arguments reversed will have different results. * @param T first type from which keys will be pulled * @param U second type from which keys will be pulled * @returns keys of `T` minus the keys of `U` */ export declare type DiffKeys = Exclude; /** * Returns `True` if a key, `K`, is present in a type, `T`, else `False`. * @param T type to check for existence of key `K`. * @param K key to query `T` for * @returns `True` if `K` is a key of `T`. Else `False`. */ export declare type HasKey = K extends keyof T ? True : False; /** * @param T the union to get the keys of * @returns a union containing all the keys of members of `T` */ export declare type UnionKeys = T extends unknown ? keyof T : never; /** * Get a union of the properties of an object. * @param T the object whose property values will be unionized * @returns a union of the right-side values of `T` */ export declare type UnionizeProperties = T[keyof T]; /** * Gives back an object with listed keys removed. * This is the opposite of `Pick`. * @param T the object whose properties will be removed * @param K the union of keys to remove from `T` * @returns `T` with the keys `K` removed */ export declare type Omit = Pick>; /** * Returns only the shared properties between two objects. * All shared properties must be the same type. * @param T the first object * @param U a second object whose shared properties (keys contained in both `T` and `U`) must have the same type as those in `T` * @returns the properties that are shared between `T` and `U` */ export declare type Intersect> = Omit>; /** * Can change the types of properties on an object. * This is similar to `Merge`, except that it will not add previously non-existent properties to the object. * @param T the object whose properties will be overwritten * @param U the object who will overwrite `T` * @returns `T` with properties overwritten with values in `U` */ export declare type Overwrite = { [k in keyof T]: k extends keyof U ? U[k] : T[k]; }; /** * Much like `_.merge` in javascript, this returns an object with all keys present between both objects, but conflicts resolved by rightmost object. * @param T the object whose properties will be overwritten * @param U the object whose properties will be present _as is_ in the resultant object * @returns an object containing all of `U` and properties of `T` not present in `U` */ export declare type Merge = Overwrite & U; /** * For discriminated unions of objects, it is important to have a single "tag" property. * Creates an object with each entry being tagged by the key defining that entry. * @param T a Record of objects * @param Key the key to add to each inner object as the tag property * @returns a record where each key of the record is now the `Key` property of the inner object */ export declare type TaggedObject, Key extends keyof any> = { [K in keyof T]: T[K] & Record; }; /** * Uses `Partial` to make every parameter of an object optional (`| undefined`). * Iterates through arrays of objects and nested objects. * @param T the type to take a partial of. Can be deeply nested. * @returns `Partial` recursively through all properties of `T` */ export declare type DeepPartial = Partial<{ [k in keyof T]: T[k] extends unknown[] ? Array> : T[k] extends Function ? T[k] : T[k] extends object ? DeepPartial : T[k]; }>; /** * Marks all keys as required. * @param T object whose keys will be marked required * @returns `T` with all fields marked required */ export declare type AllRequired = { [K in keyof T]-?: NonNullable; }; /** * Mark specific keys, `K`, of `T` as required. * @param T object whose keys will be marked required * @param K keys of `T` that will be marked required * @returns `T` with keys, `K`, marked as required */ export declare type Required = CombineObjects<{ [k in K]-?: NonNullable; }, Omit>; /** * Mark specific keys, `K`, of `T` as optional (think `Partial`). * @param T object whose keys will be marked optional * @param K keys of `T` that will be marked optional * @returns `T` with keys, `K`, marked as optional */ export declare type Optional = CombineObjects<{ [k in K]?: T[k] | undefined; }, Omit>; /** * Uses `Readonly` to make every parameter of an object - and its sub-objects recursively - readonly. * @param T type to be recursively traversed with keys marked as readonly * @returns `T` with all keys recursively marked as readonly */ export declare type DeepReadonly = Readonly<{ [k in keyof T]: T[k] extends unknown[] ? ReadonlyArray> : T[k] extends Function ? T[k] : T[k] extends object ? DeepReadonly : T[k]; }>; /** * Gets all keys that point to a given type. * @param O the object whose keys will be returned * @param T the type to filter by * @returns keys of `O` whose right-side value is `T` */ export declare type KeysByType = { [k in keyof O]-?: O[k] extends T ? k : never; }[keyof O]; /** * Builds the type of any constructor function for a particular object. * @param T the object to build a constructor for * @returns a constructor for `T` with the prototype set to `T` */ export interface ConstructorFor { new (...args: any[]): T; prototype: T; } /** * Makes a union 'strict', such that members are disallowed from including the keys of other members * For example, `{x: 1, y: 1}` is a valid member of `{x: number} | {y: number}`, * but it's not a valid member of StrictUnion<{x: number} | {y: number}>. * @param T a union type * @returns a the strict version of `T` */ export declare type StrictUnion = _StrictUnionHelper; /** no-doc */ export declare type _StrictUnionHelper = UnionMember extends unknown ? UnionMember & Partial, keyof UnionMember>, never>> : never;