///
///
/** Placeholder that sometimes helps force TS to display what you want it to. */
type _ = T;
/** Make all properties in T optional */
type Partial = { [P in keyof T]?: T[P] };
/** Make all properties in T required */
type Required = { [P in keyof T]-?: T[P] };
/** Make all properties in T readonly */
type Readonly = { readonly [P in keyof T]: T[P] };
/** Make all properties in T non-readonly. */
type Writable = { -readonly [P in keyof T]: T[P] };
/** From T pick a set of properties K */
type Pick = { [P in K]: T[P] };
/** Returns a subset of type T which excludes properties K */
type Omit = Pick>;
/** Construct a type with a set of properties K of type T */
type Record = { [P in K]: T };
/** Exclude from T those types that are assignable to U */
type Exclude = T extends U ? never : T;
/** Extract from T those types that are assignable to U */
type Extract = T extends U ? T : never;
/** Returns a union of all the keys of T whose values extend from U */
type ExtractKeys = { [K in keyof T]-?: T[K] extends U ? K : never }[keyof T];
/** Returns a new object type of all the keys of T whose values extend from U */
type ExtractMembers = Pick>;
/** Returns a union of all the keys of T whose values do not extend from U */
type ExcludeKeys = { [K in keyof T]-?: T[K] extends U ? never : K }[keyof T];
/** Returns a new object type of all the keys of T whose values do not extend from U */
type ExcludeMembers = Pick>;
/** Exclude null and undefined from T */
type NonNullable = T & {};
/** Obtain the parameters of a function type in a `tuple | never`. */
type Parameters = T extends (...args: infer P) => any ? P : never;
/** Obtain the parameters of a constructor function type in a `tuple | never` */
type ConstructorParameters any> = T extends new (...args: infer P) => any ? P : never;
/** Obtain the return type of a function type */
type ReturnType = T extends (...args: Array) => infer R ? R : never;
/** Returns the type of `this` for a given function type */
type InferThis = T extends (this: infer U, ...parameters: Array) => any ? U : never;
/** Obtain the return type of a constructor function type */
type InstanceType = T extends new (...args: Array) => infer R ? R : never;
/** Combines a series of intersections into one object, e.g. { x: number } & { y: number } becomes { x: number, y: number } */
type Reconstruct = _<{ [K in keyof T]: T[K] }>;
/** Converts a series of object unions to a series of intersections, e.g. A | B becomes A & B */
type UnionToIntersection = (T extends object ? (k: T) => void : never) extends (k: infer U) => void ? U : never;
/** Extracts the type of the 'this' parameter of a function type, or 'unknown' if the function type has no 'this' parameter. */
type ThisParameterType = T extends (this: infer U, ...args: Array) => any ? U : unknown;
/** Removes the 'this' parameter from a function type. */
type OmitThisParameter =
unknown extends ThisParameterType ? T : T extends (...args: infer A) => infer R ? (...args: A) => R : T;
/** Given an object `T`, returns a unioned type of all non-readonly property names. */
type WritablePropertyNames = {
[K in keyof T]-?: T[K] extends Callback
? never
: (() => F extends { [Q in K]: T[K] } ? 1 : 2) extends () => F extends {
-readonly [Q in K]: T[K];
}
? 1
: 2
? K
: never;
}[keyof T];
/** Given an object `T`, returns an object with readonly fields filtered out. */
type WritableProperties = Pick>;
/** Given an Instance `T`, returns a unioned type of all property names. */
type InstancePropertyNames = Exclude<
ExcludeKeys,
"Changed"
>;
/** Given an Instance `T`, returns a unioned type of all method names. */
type InstanceMethodNames = ExtractKeys;
/** Given an Instance `T`, returns a unioned type of all event names. */
type InstanceEventNames = ExtractKeys;
/** Given an Instance `T`, returns an object with only properties. */
type InstanceProperties = Pick>;
/** Given an Instance `T`, returns an object with only methods. */
type InstanceMethods = Pick>;
/** Given an Instance `T`, returns an object with only events. */
type InstanceEvents = Pick>;
/** Given an Instance `T`, returns an object with readonly fields, methods, and events filtered out. */
type WritableInstanceProperties = WritableProperties>;
/** Returns a union of all the keys of T which do not start with `_nominal_` */
type ExcludeNominalKeys = {
[K in keyof T]-?: K extends `_nominal_${infer _U}` ? never : K;
}[keyof T];
/** Returns a new object type of all the keys of T which do not start with `_nominal_` */
type ExcludeNominalMembers = Pick>;
/** Unwraps a Promise */
type Awaited = T extends PromiseLike ? U : T;