export type OptionalExceptFor = Partial>> & Required>; export type StringMap = { [key in keyof T]: string; }; export type Await = T extends PromiseLike ? U : T; export type ValueOf = T[keyof T]; export type DeepPartial = T extends object ? { [P in keyof T]?: DeepPartial; } : T; /** A union type that represents a value that can be directly awaited or a promise that will eventually resolve to a value of type T. */ export type Awaitable = Awaited | Promise>; /** * This is a helper type that takes a type T and returns a type that is the same as T, but with all * properties that are functions removed. * * @example * ```ts * type Foo = { * bar: string; * qux: () => void; * } * * type FooWithoutFunctions = RemoveFunctions; * * // FooWithoutFunctions is equivalent to: * type FooWithoutFunctions = { * bar: string; * } * ``` */ export type RemoveFunctions = Pick; type MissingKeys = Exclude; /** * A utility function that checks if the provided keys are valid for the given type T. * The key thing it does is to ensure that all keys in T are present in the array, typescript can check for extra keys but not missing keys. * While it is a function, it is really just a type check. The function is needed to encapsulate the type logic. * It will throw a type error if any of the keys are not present in T. * * @example * ```ts * type Foo = { * bar: string; * qux?: string; * }; * * const fooChecker = makeKeyChecker(); * const allFooKeys = fooChecker(['bar', 'qux']); // Valid * fooChecker(['bar']); // Error: Missing keys: qux * fooChecker(['qux']); // Error: Missing keys: bar * fooChecker(['bar', 'qux', 'baz']); // 'baz' is not assignable to type keyof Foo; * ``` */ export declare const makeKeyChecker: () => (arr: K & (MissingKeys extends never ? unknown : `Error: Missing keys: ${string & MissingKeys}`)) => K; export {};