/// /** * BasicPrimitive * @desc Type representing * [`BasicPrimitive`](https://www.typescriptlang.org/docs/handbook/release-notes/overview.html#smarter-type-alias-preservation) * types in TypeScript */ type BasicPrimitive = number | string | boolean; /** * Primitive * @desc Type representing [`Primitive`](https://developer.mozilla.org/en-US/docs/Glossary/Primitive) types * in TypeScript: `string | number | bigint | boolean | symbol | null | undefined` */ export type Primitive = BasicPrimitive | null | bigint | symbol | undefined; /** * JsonTypes * @desc Type representing JSON types in TypeScript */ type JsonType = BasicPrimitive | null | object | (BasicPrimitive | object)[]; /** * Builtin * @desc Type representing Builtin types in JavaScript */ export type Builtin = | Primitive | Function | String | Number | Date | Error | RegExp | Buffer | ArrayBuffer | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | URL | ReadableStream | WritableStream; /** * Type * @desc Represents constructor of type T */ export interface Type { new (...args: any[]): T; } /** * Class * @desc Represents Class constructor of type T */ export type Class< Args extends any[] = any[], Instance = {}, Static = {}, > = (new (...args: Args) => Instance) & Static; /** * Maybe * @desc Type representing T | undefined */ export type Maybe = T | undefined; /** * Nullish * @desc Type representing T | undefined | null */ export type Nullish = T | undefined | null; export type Awaited = T extends PromiseLike ? U : T; export type Thunk = T | (() => T); export type ThunkAsync = Thunk | (() => Promise); export type TypeThunk = Thunk>; export type TypeThunkAsync = ThunkAsync>; export type MaybePromise = T | Promise; /** * PropertyType * @desc Returns the type of property at a given key `K` */ export type PropertyType = T[K]; /** * $ElementType * @desc Returns the type of elements inside of array, tuple or object of type `T`, that matches the given index type `K` */ export type ElementType< T extends { [P in K & any]: any }, K extends keyof T | number, > = T[K];