/** * Represents any plain function (no `this`) */ export type AnyFunction = (...args: any[]) => any; export type UnknownFunction = (...args: unknown[]) => unknown; /** * Represents any plain object (or Record, as TypeScript calls it). * * Prefer {@link UnknownRecord} unless you're encountering issues with it. */ export type AnyRecord = Record; /** * Represents any plain object (or Record, as TypeScript calls it) * * Stricter than {@link AnyRecord}. Not all records can be assigned to this value due to how TypeScript works * but its usage is recommended because the value won't be typed as any. */ export type UnknownRecord = Record; export type Nullish = null | undefined; export type NonNullish = {}; /** * Makes the type accept null & undefined */ export type MakeNullish = T | Nullish; export type MakeNonNullish = NonNullable; export type NonUndefined = T extends undefined ? never : T; export type NonNull = T extends null ? never : T; export type NonUndefinedKeys = { [P in keyof T]: P extends K ? NonUndefined : T[P]; }; export type AllowArray = T | T[]; export type AllowIterable = T | Iterable; export type AllowReadonlyArray = T | readonly T[]; export type AllowPromise = T | Promise; /** * Like {@link Partial}, but also allows undefined. * Useful when "exactOptionalPropertyTypes" is enabled. */ export type PartialOrUndefined = { [P in keyof T]?: T[P] | undefined; }; /** * Type helper for making certain fields of an object optional. */ export type PartialBy = Omit & Partial>; export type RequiredBy = Omit & Required>; export type StrictRequiredBy = NonUndefinedKeys & Required>, K>; export type ReadOnlyRecord = Readonly>; export type PartialRecord = { [P in K]?: V; }; export type PartialReadonlyRecord = Readonly>; export type Entry = [key: Key, value: Value]; export type JsonArray = JsonValue[]; export type JsonObject = { [key: string]: JsonValue; }; export type JsonPrimitive = string | number | boolean | null; export type JsonValue = JsonPrimitive | JsonObject | JsonArray; export type PickByType = { [K in keyof T as U extends T[K] ? K : never]: T[K]; }; export interface ReadonlyMapLike { entries(): IterableIterator>; get(key: K): V | undefined; has(key: K): boolean; keys(): IterableIterator; readonly size: number; [Symbol.iterator](): IterableIterator>; values(): IterableIterator; } export interface MapLike extends ReadonlyMapLike { clear(): void; delete(key: K): boolean; set(key: K, value: V): this; } export interface ReadonlySetLike { has(value: V): boolean; readonly size: number; [Symbol.iterator](): IterableIterator; values(): IterableIterator; } export interface SetLike extends ReadonlySetLike { add(value: V): this; clear(): void; delete(value: V): boolean; }